diff --git a/dom/animation/AnimationUtils.cpp b/dom/animation/AnimationUtils.cpp index 759de1758406..a632496625ab 100644 --- a/dom/animation/AnimationUtils.cpp +++ b/dom/animation/AnimationUtils.cpp @@ -10,10 +10,13 @@ #include "nsDebug.h" #include "nsIAtom.h" #include "nsIContent.h" +#include "nsIDocument.h" +#include "nsGlobalWindow.h" #include "nsString.h" #include "mozilla/Attributes.h" #include "mozilla/ComputedTimingFunction.h" // ComputedTimingFunction #include "mozilla/dom/Element.h" // For dom::Element +#include "xpcpublic.h" // For xpc::CurrentWindowOrNull namespace mozilla { @@ -99,4 +102,14 @@ AnimationUtils::ParseEasing(const dom::Element* aTarget, return Nothing(); } +/* static */ nsIDocument* +AnimationUtils::GetCurrentRealmDocument(JSContext* aCx) +{ + nsGlobalWindow* win = xpc::CurrentWindowOrNull(aCx); + if (!win) { + return nullptr; + } + return win->GetDoc(); +} + } // namespace mozilla diff --git a/dom/animation/AnimationUtils.h b/dom/animation/AnimationUtils.h index 3ecadb18a6dc..0c26e0ada8e7 100644 --- a/dom/animation/AnimationUtils.h +++ b/dom/animation/AnimationUtils.h @@ -12,6 +12,8 @@ #include "nsStringFwd.h" class nsIContent; +class nsIDocument; +struct JSContext; namespace mozilla { @@ -58,6 +60,12 @@ public: */ static Maybe ParseEasing(const dom::Element* aTarget, const nsAString& aEasing); + + /** + * Get the document from the JS context to use when parsing CSS properties. + */ + static nsIDocument* + GetCurrentRealmDocument(JSContext* aCx); }; } // namespace mozilla