diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /dom/xhr/XMLHttpRequest.h | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/xhr/XMLHttpRequest.h')
-rw-r--r-- | dom/xhr/XMLHttpRequest.h | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/dom/xhr/XMLHttpRequest.h b/dom/xhr/XMLHttpRequest.h index 0d82f8c035..a7c4c0550c 100644 --- a/dom/xhr/XMLHttpRequest.h +++ b/dom/xhr/XMLHttpRequest.h @@ -29,9 +29,12 @@ class XMLHttpRequest : public XMLHttpRequestEventTarget { const char* cStr; const char16_t* str; - EventType(const char* name, const char16_t* uname) + constexpr EventType(const char* name, const char16_t* uname) : cStr(name), str(uname) {} + constexpr EventType(const EventType& other) + : cStr(other.cStr), str(other.str) {} + operator const nsDependentString() const { return nsDependentString(str); } friend bool operator==(const EventType& a, const EventType& b) { @@ -56,55 +59,26 @@ class XMLHttpRequest : public XMLHttpRequestEventTarget { }; struct ProgressEventType : public EventType { - ProgressEventType(const char* name, const char16_t* uname) + constexpr ProgressEventType(const char* name, const char16_t* uname) : EventType(name, uname) {} }; struct ErrorProgressEventType : public ProgressEventType { const nsresult errorCode; - - ErrorProgressEventType(const char* name, const char16_t* uname, - const nsresult code) + constexpr ErrorProgressEventType(const char* name, const char16_t* uname, + const nsresult code) : ProgressEventType(name, uname), errorCode(code) {} }; -#define DECL_EVENT(NAME) \ - static inline const EventType NAME = EventType(#NAME, u## #NAME); - -#define DECL_PROGRESSEVENT(NAME) \ - static inline const ProgressEventType NAME = \ - ProgressEventType(#NAME, u## #NAME); - -#define DECL_ERRORPROGRESSEVENT(NAME, ERR) \ - static inline const ErrorProgressEventType NAME = \ - ErrorProgressEventType(#NAME, u## #NAME, ERR); - - struct Events { - DECL_EVENT(readystatechange); - DECL_PROGRESSEVENT(loadstart); - DECL_PROGRESSEVENT(progress); - DECL_ERRORPROGRESSEVENT(error, NS_ERROR_DOM_NETWORK_ERR); - DECL_ERRORPROGRESSEVENT(abort, NS_ERROR_DOM_ABORT_ERR); - DECL_ERRORPROGRESSEVENT(timeout, NS_ERROR_DOM_TIMEOUT_ERR); - DECL_PROGRESSEVENT(load); - DECL_PROGRESSEVENT(loadend); - - static inline const EventType* All[]{ - &readystatechange, &loadstart, &progress, &error, &abort, - &timeout, &load, &loadend}; - - static inline const EventType* ProgressEvents[]{ - &loadstart, &progress, &error, &abort, &timeout, &load, &loadend}; - - static inline const EventType* Find(const nsString& name) { - for (const EventType* type : Events::All) { - if (*type == name) { - return type; - } - } - return nullptr; - } - }; +#define DECL_EVENT(NAME) static constexpr EventType NAME{#NAME, u## #NAME}; + +#define DECL_PROGRESSEVENT(NAME) \ + static constexpr ProgressEventType NAME { #NAME, u## #NAME } + +#define DECL_ERRORPROGRESSEVENT(NAME, ERR) \ + static constexpr ErrorProgressEventType NAME{#NAME, u## #NAME, ERR}; + + struct Events; static already_AddRefed<XMLHttpRequest> Constructor( const GlobalObject& aGlobal, const MozXMLHttpRequestParameters& aParams, @@ -216,6 +190,33 @@ class XMLHttpRequest : public XMLHttpRequestEventTarget { : XMLHttpRequestEventTarget(aGlobalObject) {} }; +struct XMLHttpRequest::Events { + DECL_EVENT(readystatechange); + DECL_PROGRESSEVENT(loadstart); + DECL_PROGRESSEVENT(progress); + DECL_ERRORPROGRESSEVENT(error, NS_ERROR_DOM_NETWORK_ERR); + DECL_ERRORPROGRESSEVENT(abort, NS_ERROR_DOM_ABORT_ERR); + DECL_ERRORPROGRESSEVENT(timeout, NS_ERROR_DOM_TIMEOUT_ERR); + DECL_PROGRESSEVENT(load); + DECL_PROGRESSEVENT(loadend); + + static inline const EventType* All[]{ + &readystatechange, &loadstart, &progress, &error, &abort, + &timeout, &load, &loadend}; + + static inline const EventType* ProgressEvents[]{ + &loadstart, &progress, &error, &abort, &timeout, &load, &loadend}; + + static inline const EventType* Find(const nsString& name) { + for (const EventType* type : Events::All) { + if (*type == name) { + return type; + } + } + return nullptr; + } +}; + } // namespace mozilla::dom #endif // mozilla_dom_XMLHttpRequest_h |