mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Add getters and setters to IDBRequest
This commit is contained in:
parent
914ad7bbd6
commit
ef75cc53f9
Notes:
github-actions[bot]
2024-11-08 18:11:44 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/ef75cc53f98 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2165 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/shannonbooth
3 changed files with 31 additions and 2 deletions
|
@ -27,6 +27,13 @@ void IDBRequest::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBRequest);
|
||||
}
|
||||
|
||||
void IDBRequest::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_error);
|
||||
visitor.visit(m_result);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#dom-idbrequest-onsuccess
|
||||
void IDBRequest::set_onsuccess(WebIDL::CallbackType* event_handler)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,16 @@ class IDBRequest : public DOM::EventTarget {
|
|||
public:
|
||||
virtual ~IDBRequest() override;
|
||||
|
||||
[[nodiscard]] JS::Value result() const { return m_result; }
|
||||
[[nodiscard]] JS::GCPtr<WebIDL::DOMException> error() const { return m_error; }
|
||||
[[nodiscard]] bool done() const { return m_done; }
|
||||
[[nodiscard]] bool processed() const { return m_processed; }
|
||||
|
||||
void set_done(bool done) { m_done = done; }
|
||||
void set_result(JS::Value result) { m_result = result; }
|
||||
void set_error(JS::GCPtr<WebIDL::DOMException> error) { m_error = error; }
|
||||
void set_processed(bool processed) { m_processed = processed; }
|
||||
|
||||
void set_onsuccess(WebIDL::CallbackType*);
|
||||
WebIDL::CallbackType* onsuccess();
|
||||
void set_onerror(WebIDL::CallbackType*);
|
||||
|
@ -27,6 +37,18 @@ protected:
|
|||
explicit IDBRequest(JS::Realm&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Visitor& visitor) override;
|
||||
|
||||
private:
|
||||
// A request has a processed flag which is initially false.
|
||||
bool m_processed { false };
|
||||
// A request has a done flag which is initially false.
|
||||
bool m_done { false };
|
||||
// A request has a result and an error
|
||||
JS::Value m_result;
|
||||
JS::GCPtr<WebIDL::DOMException> m_error;
|
||||
// FIXME: A request has a source object.
|
||||
// FIXME: A request has a transaction which is initially null.
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
// https://w3c.github.io/IndexedDB/#idbrequest
|
||||
[Exposed=(Window,Worker)]
|
||||
interface IDBRequest : EventTarget {
|
||||
[FIXME] readonly attribute any result;
|
||||
[FIXME] readonly attribute DOMException? error;
|
||||
readonly attribute any result;
|
||||
readonly attribute DOMException? error;
|
||||
[FIXME] readonly attribute (IDBObjectStore or IDBIndex or IDBCursor)? source;
|
||||
[FIXME] readonly attribute IDBTransaction? transaction;
|
||||
[FIXME] readonly attribute IDBRequestReadyState readyState;
|
||||
|
|
Loading…
Reference in a new issue