Bug 1190881 - Part 1. Create and pass a navigation timing object to the wrapped SVG document. draft
authorcku <cku@mozilla.com>
Tue, 23 Aug 2016 21:29:30 +0800
changeset 405982 8e820cfa7ebba144e68768cbed9a8f5aee3304e8
parent 404988 01748a2b1a463f24efd9cd8abad9ccfd76b037b8
child 405983 f4e1aa734ff4c1d9643a2a52be15fb20ca660414
push id27624
push userbmo:cku@mozilla.com
push dateFri, 26 Aug 2016 08:51:43 +0000
bugs1190881
milestone51.0a1
Bug 1190881 - Part 1. Create and pass a navigation timing object to the wrapped SVG document. MozReview-Commit-ID: EriBoKMUvl3
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);