Bug 1190881 - Part 1. Create and pass a navigation timing object to the wrapped SVG document. draft
authorcku <cku@mozilla.com>
Fri, 02 Sep 2016 18:53:36 +0800
changeset 409943 c3ca7426e9c827644e181b115f3152b6bec01a07
parent 409737 dbe4b47941c7b3d6298a0ead5e40dd828096c808
child 409944 b69207e0be4b711a3d25b8f6fe1f7967bfb7bba5
push id28615
push userbmo:cku@mozilla.com
push dateMon, 05 Sep 2016 18:28:08 +0000
bugs1190881
milestone51.0a1
Bug 1190881 - Part 1. Create and pass a navigation timing object to the wrapped SVG document. MozReview-Commit-ID: DTtTudlJ52d
image/SVGDocumentWrapper.cpp
--- a/image/SVGDocumentWrapper.cpp
+++ b/image/SVGDocumentWrapper.cpp
@@ -345,16 +345,30 @@ SVGDocumentWrapper::SetupViewer(nsIReque
                                         NS_LITERAL_CSTRING(IMAGE_SVG_XML),
                                         nullptr, nullptr,
                                         getter_AddRefs(listener),
                                         getter_AddRefs(viewer));
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_TRUE(viewer, NS_ERROR_UNEXPECTED);
 
+  // Create a navigation time object and pass it to the SVG document through
+  // the viewer.
+  // The timeline(DocumentTimeline, used in CSS animation) of this SVG
+  // document needs this navigation timing object for time computation, such
+  // as to calculate current time stamp based on the start time of navigation
+  // time object.
+  //
+  // For a root document, DocShell would do these sort of things
+  // automatically. Since there is no DocShell for this wrapped SVG document,
+  // we must set it up manually.
+  RefPtr<nsDOMNavigationTiming> timing = new nsDOMNavigationTiming();
+  timing->NotifyNavigationStart();
+  viewer->SetNavigationTiming(timing);
+
   nsCOMPtr<nsIParser> parser = do_QueryInterface(listener);
   NS_ENSURE_TRUE(parser, NS_ERROR_UNEXPECTED);
 
   // XML-only, because this is for SVG content
   nsIContentSink* sink = parser->GetContentSink();
   nsCOMPtr<nsIXMLContentSink> xmlSink = do_QueryInterface(sink);
   NS_ENSURE_TRUE(sink, NS_ERROR_UNEXPECTED);