Changeset 214322 in webkit


Ignore:
Timestamp:
Mar 23, 2017, 3:40:50 PM (8 years ago)
Author:
Chris Dumez
Message:

SVG animations are not paused when inserted into a hidden page
https://bugs.webkit.org/show_bug.cgi?id=170026
<rdar://problem/31228704>

Reviewed by Andreas Kling.

Source/WebCore:

SVG animations were not paused when inserted into a hidden page. We would pause
animations in a page when the page becomes hidden. However, new animations
inserted in the page after this point would start, despite the page being
hidden.

Tests:

  • svg/animations/animations-paused-when-inserted-in-hidden-document.html
  • svg/animations/animations-paused-when-inserted-in-hidden-document2.html
  • dom/Document.cpp:

(WebCore::Document::accessSVGExtensions):

  • svg/SVGDocumentExtensions.cpp:

(WebCore::SVGDocumentExtensions::SVGDocumentExtensions):
(WebCore::SVGDocumentExtensions::addTimeContainer):
(WebCore::reportMessage):

  • svg/SVGDocumentExtensions.h:
  • testing/Internals.cpp:

(WebCore::Internals::areSVGAnimationsPaused):

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

Add layout test coverage.

  • svg/animations/animations-paused-when-inserted-in-hidden-document-expected.txt: Added.
  • svg/animations/animations-paused-when-inserted-in-hidden-document.html: Added.
  • svg/animations/animations-paused-when-inserted-in-hidden-document2-expected.txt: Added.
  • svg/animations/animations-paused-when-inserted-in-hidden-document2.html: Added.
Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r214321 r214322  
     12017-03-23  Chris Dumez  <cdumez@apple.com>
     2
     3        SVG animations are not paused when inserted into a hidden page
     4        https://bugs.webkit.org/show_bug.cgi?id=170026
     5        <rdar://problem/31228704>
     6
     7        Reviewed by Andreas Kling.
     8
     9        Add layout test coverage.
     10
     11        * svg/animations/animations-paused-when-inserted-in-hidden-document-expected.txt: Added.
     12        * svg/animations/animations-paused-when-inserted-in-hidden-document.html: Added.
     13        * svg/animations/animations-paused-when-inserted-in-hidden-document2-expected.txt: Added.
     14        * svg/animations/animations-paused-when-inserted-in-hidden-document2.html: Added.
     15
    116== Rolled over to ChangeLog-2017-03-23 ==
  • trunk/Source/WebCore/ChangeLog

    r214321 r214322  
     12017-03-23  Chris Dumez  <cdumez@apple.com>
     2
     3        SVG animations are not paused when inserted into a hidden page
     4        https://bugs.webkit.org/show_bug.cgi?id=170026
     5        <rdar://problem/31228704>
     6
     7        Reviewed by Andreas Kling.
     8
     9        SVG animations were not paused when inserted into a hidden page. We would pause
     10        animations in a page when the page becomes hidden. However, new animations
     11        inserted in the page after this point would start, despite the page being
     12        hidden.
     13
     14        Tests:
     15        - svg/animations/animations-paused-when-inserted-in-hidden-document.html
     16        - svg/animations/animations-paused-when-inserted-in-hidden-document2.html
     17
     18        * dom/Document.cpp:
     19        (WebCore::Document::accessSVGExtensions):
     20        * svg/SVGDocumentExtensions.cpp:
     21        (WebCore::SVGDocumentExtensions::SVGDocumentExtensions):
     22        (WebCore::SVGDocumentExtensions::addTimeContainer):
     23        (WebCore::reportMessage):
     24        * svg/SVGDocumentExtensions.h:
     25        * testing/Internals.cpp:
     26        (WebCore::Internals::areSVGAnimationsPaused):
     27        * testing/Internals.h:
     28        * testing/Internals.idl:
     29
    130== Rolled over to ChangeLog-2017-03-23 ==
  • trunk/Source/WebCore/dom/Document.cpp

    r214203 r214322  
    48744874{
    48754875    if (!m_svgExtensions)
    4876         m_svgExtensions = std::make_unique<SVGDocumentExtensions>(this);
     4876        m_svgExtensions = std::make_unique<SVGDocumentExtensions>(*this);
    48774877    return *m_svgExtensions;
    48784878}
  • trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp

    r211612 r214322  
    2828#include "Frame.h"
    2929#include "FrameLoader.h"
     30#include "Page.h"
    3031#include "SMILTimeContainer.h"
    3132#include "SVGElement.h"
     
    4041namespace WebCore {
    4142
    42 SVGDocumentExtensions::SVGDocumentExtensions(Document* document)
     43SVGDocumentExtensions::SVGDocumentExtensions(Document& document)
    4344    : m_document(document)
    4445    , m_resourcesCache(std::make_unique<SVGResourcesCache>())
     46    , m_areAnimationsPaused(!document.page() || !document.page()->isVisible())
    4547{
    4648}
     
    5355{
    5456    m_timeContainers.add(element);
     57    if (m_areAnimationsPaused)
     58        element->pauseAnimations();
    5559}
    5660
     
    125129}
    126130
    127 static void reportMessage(Document* document, MessageLevel level, const String& message)
    128 {
    129     if (document->frame())
    130         document->addConsoleMessage(MessageSource::Rendering, level, message);
     131static void reportMessage(Document& document, MessageLevel level, const String& message)
     132{
     133    if (document.frame())
     134        document.addConsoleMessage(MessageSource::Rendering, level, message);
    131135}
    132136
  • trunk/Source/WebCore/svg/SVGDocumentExtensions.h

    r211612 r214322  
    4141public:
    4242    typedef HashSet<Element*> PendingElements;
    43     explicit SVGDocumentExtensions(Document*);
     43    explicit SVGDocumentExtensions(Document&);
    4444    ~SVGDocumentExtensions();
    4545   
     
    7878
    7979private:
    80     Document* m_document; // weak reference
     80    Document& m_document;
    8181    HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general.
    8282#if ENABLE(SVG_FONTS)
     
    9090
    9191    Vector<SVGElement*> m_rebuildElements;
    92     bool m_areAnimationsPaused { false }; // For testing.
     92    bool m_areAnimationsPaused;
    9393
    9494public:
  • trunk/Source/WebCore/testing/Internals.cpp

    r214266 r214322  
    518518}
    519519
    520 bool Internals::areSVGAnimationsPaused() const
     520ExceptionOr<bool> Internals::areSVGAnimationsPaused() const
    521521{
    522522    auto* document = contextDocument();
    523523    if (!document)
    524         return false;
     524        return Exception { INVALID_ACCESS_ERR, ASCIILiteral("No context document") };
    525525
    526526    if (!document->svgExtensions())
    527         return false;
     527        return Exception { NOT_FOUND_ERR, ASCIILiteral("No SVG animations") };
    528528
    529529    return document->accessSVGExtensions().areAnimationsPaused();
  • trunk/Source/WebCore/testing/Internals.h

    r214113 r214322  
    267267    InternalSettings* settings() const;
    268268    unsigned workerThreadCount() const;
    269     bool areSVGAnimationsPaused() const;
     269    ExceptionOr<bool> areSVGAnimationsPaused() const;
    270270    ExceptionOr<double> svgAnimationsInterval(SVGSVGElement&) const;
    271271
  • trunk/Source/WebCore/testing/Internals.idl

    r214113 r214322  
    250250    readonly attribute unsigned long workerThreadCount;
    251251
    252     readonly attribute boolean areSVGAnimationsPaused;
     252    [MayThrowException] readonly attribute boolean areSVGAnimationsPaused;
    253253    [MayThrowException] double svgAnimationsInterval(SVGSVGElement element);
    254254
Note: See TracChangeset for help on using the changeset viewer.