mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibJS: Handle both const and non-const Ts in Handle<T>::create()
Again, the const-ness only really involves Heap-internal metadata, so the callers shouldn't care about mutations here.
This commit is contained in:
parent
74e93a46ea
commit
70a2ca7fc0
Notes:
sideshowbarker
2024-07-17 16:23:55 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/70a2ca7fc0 Pull-request: https://github.com/SerenityOS/serenity/pull/17620 Issue: https://github.com/SerenityOS/serenity/issues/16988 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/linusg
6 changed files with 10 additions and 10 deletions
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
static Handle create(T* cell)
|
||||
{
|
||||
return Handle(adopt_ref(*new HandleImpl(cell)));
|
||||
return Handle(adopt_ref(*new HandleImpl(const_cast<RemoveConst<T>*>(cell))));
|
||||
}
|
||||
|
||||
Handle(T* cell)
|
||||
|
|
|
@ -2121,7 +2121,7 @@ Vector<JS::Handle<HTML::BrowsingContext>> Document::list_of_descendant_browsing_
|
|||
// of this document's browsing context.
|
||||
if (browsing_context()) {
|
||||
browsing_context()->for_each_in_subtree([&](auto& context) {
|
||||
list.append(JS::make_handle(const_cast<HTML::BrowsingContext&>(context)));
|
||||
list.append(JS::make_handle(context));
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -838,7 +838,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_fetch(JS::Realm& rea
|
|||
// NOTE: Step 2 is performed in pending_preflight_response's load callback below.
|
||||
}
|
||||
|
||||
auto fetch_main_content = [request = JS::make_handle(request), realm = JS::make_handle(realm), fetch_params = JS::make_handle(const_cast<Infrastructure::FetchParams&>(fetch_params))]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> {
|
||||
auto fetch_main_content = [request = JS::make_handle(request), realm = JS::make_handle(realm), fetch_params = JS::make_handle(fetch_params)]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> {
|
||||
// 2. If request’s redirect mode is "follow", then set request’s service-workers mode to "none".
|
||||
// NOTE: Redirects coming from the network (as opposed to from a service worker) are not to be exposed to a
|
||||
// service worker.
|
||||
|
|
|
@ -52,11 +52,11 @@ void PendingResponse::resolve(JS::NonnullGCPtr<Infrastructure::Response> respons
|
|||
run_callback();
|
||||
}
|
||||
|
||||
void PendingResponse::run_callback() const
|
||||
void PendingResponse::run_callback()
|
||||
{
|
||||
VERIFY(m_callback);
|
||||
VERIFY(m_response);
|
||||
Platform::EventLoopPlugin::the().deferred_invoke([strong_this = JS::make_handle(const_cast<PendingResponse&>(*this))] {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke([strong_this = JS::make_handle(*this)] {
|
||||
strong_this->m_callback(*strong_this->m_response);
|
||||
strong_this->m_request->remove_pending_response({}, *strong_this.ptr());
|
||||
});
|
||||
|
|
|
@ -35,7 +35,7 @@ private:
|
|||
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
void run_callback() const;
|
||||
void run_callback();
|
||||
|
||||
Callback m_callback;
|
||||
JS::NonnullGCPtr<Infrastructure::Request> m_request;
|
||||
|
|
|
@ -84,13 +84,13 @@ Vector<JS::Handle<HTMLOptionElement>> HTMLSelectElement::list_of_options() const
|
|||
// and all the option element children of all the optgroup element children of the select element, in tree order.
|
||||
Vector<JS::Handle<HTMLOptionElement>> list;
|
||||
|
||||
for_each_child_of_type<HTMLOptionElement>([&](HTMLOptionElement const& option_element) {
|
||||
list.append(JS::make_handle(const_cast<HTMLOptionElement&>(option_element)));
|
||||
for_each_child_of_type<HTMLOptionElement>([&](HTMLOptionElement& option_element) {
|
||||
list.append(JS::make_handle(option_element));
|
||||
});
|
||||
|
||||
for_each_child_of_type<HTMLOptGroupElement>([&](HTMLOptGroupElement const& optgroup_element) {
|
||||
optgroup_element.for_each_child_of_type<HTMLOptionElement>([&](HTMLOptionElement const& option_element) {
|
||||
list.append(JS::make_handle(const_cast<HTMLOptionElement&>(option_element)));
|
||||
optgroup_element.for_each_child_of_type<HTMLOptionElement>([&](HTMLOptionElement& option_element) {
|
||||
list.append(JS::make_handle(option_element));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue