зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1246320 part 1 - Add AnimationUtils::GetCurrentRealmDocument; r=bz
Adds a utility function for getting the document on the global associated with a JSContext. We will need this in various situations where we want to use the CSS parser (which requires various bits of state we pull off a document) to parse a timing function but might not have a target element. Strictly speaking we currently always have a target element but in future we expect to support creating KeyframeEffects without an associated target element. Also, we will need this for some situations in bug 1245748 where we need to parse CSS properties on keyframe objects when we may not have a target element. MozReview-Commit-ID: Klku1LFoRGp --HG-- extra : rebase_source : f2aa06aafb8fa9b212791a3e602a168f5170fcd9
This commit is contained in:
Родитель
2c723064d6
Коммит
56844c08b6
|
@ -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
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "nsStringFwd.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
struct JSContext;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -58,6 +60,12 @@ public:
|
|||
*/
|
||||
static Maybe<ComputedTimingFunction>
|
||||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче