mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
This commit is contained in:
parent
689ca370d4
commit
359d6e7b0b
Notes:
sideshowbarker
2024-07-17 05:06:13 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/359d6e7b0b
111 changed files with 517 additions and 503 deletions
|
@ -144,13 +144,13 @@ protected:
|
|||
Queue& get_queue(u16 queue_index)
|
||||
{
|
||||
VERIFY(queue_index < m_queue_count);
|
||||
return m_queues[queue_index];
|
||||
return *m_queues[queue_index];
|
||||
}
|
||||
|
||||
Queue const& get_queue(u16 queue_index) const
|
||||
{
|
||||
VERIFY(queue_index < m_queue_count);
|
||||
return m_queues[queue_index];
|
||||
return *m_queues[queue_index];
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
|
@ -190,7 +190,7 @@ private:
|
|||
u8 isr_status();
|
||||
virtual bool handle_irq(RegisterState const&) override;
|
||||
|
||||
NonnullOwnPtrVector<Queue> m_queues;
|
||||
Vector<NonnullOwnPtr<Queue>> m_queues;
|
||||
Vector<Configuration> m_configs;
|
||||
Configuration const* m_common_cfg { nullptr }; // Cached due to high usage
|
||||
Configuration const* m_notify_cfg { nullptr }; // Cached due to high usage
|
||||
|
|
|
@ -304,9 +304,9 @@ StringView CommandLine::userspace_init() const
|
|||
return lookup("init"sv).value_or("/bin/SystemServer"sv);
|
||||
}
|
||||
|
||||
NonnullOwnPtrVector<KString> CommandLine::userspace_init_args() const
|
||||
Vector<NonnullOwnPtr<KString>> CommandLine::userspace_init_args() const
|
||||
{
|
||||
NonnullOwnPtrVector<KString> args;
|
||||
Vector<NonnullOwnPtr<KString>> args;
|
||||
|
||||
auto init_args = lookup("init_args"sv).value_or(""sv).split_view(';');
|
||||
if (!init_args.is_empty())
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
[[nodiscard]] bool is_early_boot_console_disabled() const;
|
||||
[[nodiscard]] AHCIResetMode ahci_reset_mode() const;
|
||||
[[nodiscard]] StringView userspace_init() const;
|
||||
[[nodiscard]] NonnullOwnPtrVector<KString> userspace_init_args() const;
|
||||
[[nodiscard]] Vector<NonnullOwnPtr<KString>> userspace_init_args() const;
|
||||
[[nodiscard]] StringView root_device() const;
|
||||
[[nodiscard]] bool is_nvme_polling_enabled() const;
|
||||
[[nodiscard]] size_t switch_to_tty() const;
|
||||
|
|
|
@ -287,14 +287,14 @@ ErrorOr<void> Coredump::create_notes_process_data(auto& builder) const
|
|||
{
|
||||
auto arguments_array = TRY(process_obj.add_array("arguments"sv));
|
||||
for (auto const& argument : m_process->arguments())
|
||||
TRY(arguments_array.add(argument.view()));
|
||||
TRY(arguments_array.add(argument->view()));
|
||||
TRY(arguments_array.finish());
|
||||
}
|
||||
|
||||
{
|
||||
auto environment_array = TRY(process_obj.add_array("environment"sv));
|
||||
for (auto const& variable : m_process->environment())
|
||||
TRY(environment_array.add(variable.view()));
|
||||
TRY(environment_array.add(variable->view()));
|
||||
TRY(environment_array.finish());
|
||||
}
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ ErrorOr<void> Process::procfs_get_command_line(KBufferBuilder& builder) const
|
|||
{
|
||||
auto array = TRY(JsonArraySerializer<>::try_create(builder));
|
||||
for (auto const& arg : arguments()) {
|
||||
TRY(array.add(arg.view()));
|
||||
TRY(array.add(arg->view()));
|
||||
}
|
||||
TRY(array.finish());
|
||||
return {};
|
||||
|
|
|
@ -365,7 +365,7 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map()
|
|||
}
|
||||
|
||||
for (auto& region : global_data.physical_regions)
|
||||
global_data.system_memory_info.physical_pages += region.size();
|
||||
global_data.system_memory_info.physical_pages += region->size();
|
||||
|
||||
register_reserved_ranges();
|
||||
for (auto& range : global_data.reserved_memory_ranges) {
|
||||
|
@ -384,8 +384,8 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map()
|
|||
}
|
||||
|
||||
for (auto& region : global_data.physical_regions) {
|
||||
dmesgln("MM: User physical region: {} - {} (size {:#x})", region.lower(), region.upper().offset(-1), PAGE_SIZE * region.size());
|
||||
region.initialize_zones();
|
||||
dmesgln("MM: User physical region: {} - {} (size {:#x})", region->lower(), region->upper().offset(-1), PAGE_SIZE * region->size());
|
||||
region->initialize_zones();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -425,8 +425,8 @@ UNMAP_AFTER_INIT void MemoryManager::initialize_physical_pages()
|
|||
Optional<size_t> found_region_index;
|
||||
for (size_t i = 0; i < global_data.physical_regions.size(); ++i) {
|
||||
auto& region = global_data.physical_regions[i];
|
||||
if (region.size() >= physical_page_array_pages_and_page_tables_count) {
|
||||
found_region = ®ion;
|
||||
if (region->size() >= physical_page_array_pages_and_page_tables_count) {
|
||||
found_region = region;
|
||||
found_region_index = i;
|
||||
break;
|
||||
}
|
||||
|
@ -894,10 +894,10 @@ void MemoryManager::deallocate_physical_page(PhysicalAddress paddr)
|
|||
return m_global_data.with([&](auto& global_data) {
|
||||
// Are we returning a user page?
|
||||
for (auto& region : global_data.physical_regions) {
|
||||
if (!region.contains(paddr))
|
||||
if (!region->contains(paddr))
|
||||
continue;
|
||||
|
||||
region.return_page(paddr);
|
||||
region->return_page(paddr);
|
||||
--global_data.system_memory_info.physical_pages_used;
|
||||
|
||||
// Always return pages to the uncommitted pool. Pages that were
|
||||
|
@ -925,7 +925,7 @@ RefPtr<PhysicalPage> MemoryManager::find_free_physical_page(bool committed)
|
|||
global_data.system_memory_info.physical_pages_uncommitted--;
|
||||
}
|
||||
for (auto& region : global_data.physical_regions) {
|
||||
page = region.take_free_page();
|
||||
page = region->take_free_page();
|
||||
if (!page.is_null()) {
|
||||
++global_data.system_memory_info.physical_pages_used;
|
||||
break;
|
||||
|
@ -1020,7 +1020,7 @@ ErrorOr<Vector<NonnullRefPtr<PhysicalPage>>> MemoryManager::allocate_contiguous_
|
|||
return ENOMEM;
|
||||
|
||||
for (auto& physical_region : global_data.physical_regions) {
|
||||
auto physical_pages = physical_region.take_contiguous_free_pages(page_count);
|
||||
auto physical_pages = physical_region->take_contiguous_free_pages(page_count);
|
||||
if (!physical_pages.is_empty()) {
|
||||
global_data.system_memory_info.physical_pages_uncommitted -= page_count;
|
||||
global_data.system_memory_info.physical_pages_used += page_count;
|
||||
|
|
|
@ -292,7 +292,7 @@ private:
|
|||
|
||||
SystemMemoryInfo system_memory_info;
|
||||
|
||||
NonnullOwnPtrVector<PhysicalRegion> physical_regions;
|
||||
Vector<NonnullOwnPtr<PhysicalRegion>> physical_regions;
|
||||
OwnPtr<PhysicalRegion> physical_pages_region;
|
||||
|
||||
RegionTree region_tree;
|
||||
|
|
|
@ -46,7 +46,7 @@ void PhysicalRegion::initialize_zones()
|
|||
while (remaining_pages >= pages_per_zone) {
|
||||
m_zones.append(adopt_nonnull_own_or_enomem(new (nothrow) PhysicalZone(base_address, pages_per_zone)).release_value_but_fixme_should_propagate_errors());
|
||||
base_address = base_address.offset(pages_per_zone * PAGE_SIZE);
|
||||
m_usable_zones.append(m_zones.last());
|
||||
m_usable_zones.append(*m_zones.last());
|
||||
remaining_pages -= pages_per_zone;
|
||||
++zone_count;
|
||||
}
|
||||
|
@ -131,10 +131,10 @@ void PhysicalRegion::return_page(PhysicalAddress paddr)
|
|||
zone_index = m_large_zones + (paddr.get() - small_zone_base) / small_zone_size;
|
||||
|
||||
auto& zone = m_zones[zone_index];
|
||||
VERIFY(zone.contains(paddr));
|
||||
zone.deallocate_block(paddr, 0);
|
||||
if (m_full_zones.contains(zone))
|
||||
m_usable_zones.append(zone);
|
||||
VERIFY(zone->contains(paddr));
|
||||
zone->deallocate_block(paddr, 0);
|
||||
if (m_full_zones.contains(*zone))
|
||||
m_usable_zones.append(*zone);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
static constexpr size_t large_zone_size = 16 * MiB;
|
||||
static constexpr size_t small_zone_size = 1 * MiB;
|
||||
|
||||
NonnullOwnPtrVector<PhysicalZone> m_zones;
|
||||
Vector<NonnullOwnPtr<PhysicalZone>> m_zones;
|
||||
|
||||
size_t m_large_zones { 0 };
|
||||
|
||||
|
|
|
@ -1103,7 +1103,7 @@ UNMAP_AFTER_INIT void RTL8168NetworkAdapter::initialize_rx_descriptors()
|
|||
|
||||
descriptor.buffer_size = RX_BUFFER_SIZE;
|
||||
descriptor.flags = RXDescriptor::Ownership; // let the NIC know it can use this descriptor
|
||||
auto physical_address = m_rx_buffers_regions[i].physical_page(0)->paddr().get();
|
||||
auto physical_address = m_rx_buffers_regions[i]->physical_page(0)->paddr().get();
|
||||
descriptor.buffer_address_low = physical_address & 0xFFFFFFFF;
|
||||
descriptor.buffer_address_high = (u64)physical_address >> 32; // cast to prevent shift count >= with of type warnings in 32 bit systems
|
||||
}
|
||||
|
@ -1120,7 +1120,7 @@ UNMAP_AFTER_INIT void RTL8168NetworkAdapter::initialize_tx_descriptors()
|
|||
m_tx_buffers_regions.append(move(region));
|
||||
|
||||
descriptor.flags = TXDescriptor::FirstSegment | TXDescriptor::LastSegment;
|
||||
auto physical_address = m_tx_buffers_regions[i].physical_page(0)->paddr().get();
|
||||
auto physical_address = m_tx_buffers_regions[i]->physical_page(0)->paddr().get();
|
||||
descriptor.buffer_address_low = physical_address & 0xFFFFFFFF;
|
||||
descriptor.buffer_address_high = (u64)physical_address >> 32;
|
||||
}
|
||||
|
@ -1213,7 +1213,7 @@ void RTL8168NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||
}
|
||||
|
||||
dbgln_if(RTL8168_DEBUG, "RTL8168: Chose descriptor {}", m_tx_free_index);
|
||||
memcpy(m_tx_buffers_regions[m_tx_free_index].vaddr().as_ptr(), payload.data(), payload.size());
|
||||
memcpy(m_tx_buffers_regions[m_tx_free_index]->vaddr().as_ptr(), payload.data(), payload.size());
|
||||
|
||||
m_tx_free_index = (m_tx_free_index + 1) % number_of_tx_descriptors;
|
||||
|
||||
|
@ -1247,7 +1247,7 @@ void RTL8168NetworkAdapter::receive()
|
|||
// Our maximum received packet size is smaller than the descriptor buffer size, so packets should never be segmented
|
||||
// if this happens on a real NIC it might not respect that, and we will have to support packet segmentation
|
||||
} else {
|
||||
did_receive({ m_rx_buffers_regions[descriptor_index].vaddr().as_ptr(), length });
|
||||
did_receive({ m_rx_buffers_regions[descriptor_index]->vaddr().as_ptr(), length });
|
||||
}
|
||||
|
||||
descriptor.buffer_size = RX_BUFFER_SIZE;
|
||||
|
|
|
@ -205,10 +205,10 @@ private:
|
|||
NonnullOwnPtr<IOWindow> m_registers_io_window;
|
||||
u32 m_ocp_base_address { 0 };
|
||||
OwnPtr<Memory::Region> m_rx_descriptors_region;
|
||||
NonnullOwnPtrVector<Memory::Region> m_rx_buffers_regions;
|
||||
Vector<NonnullOwnPtr<Memory::Region>> m_rx_buffers_regions;
|
||||
u16 m_rx_free_index { 0 };
|
||||
OwnPtr<Memory::Region> m_tx_descriptors_region;
|
||||
NonnullOwnPtrVector<Memory::Region> m_tx_buffers_regions;
|
||||
Vector<NonnullOwnPtr<Memory::Region>> m_tx_buffers_regions;
|
||||
u16 m_tx_free_index { 0 };
|
||||
bool m_link_up { false };
|
||||
EntropySource m_entropy_source;
|
||||
|
|
|
@ -217,7 +217,7 @@ void Process::register_new(Process& process)
|
|||
});
|
||||
}
|
||||
|
||||
ErrorOr<NonnullLockRefPtr<Process>> Process::try_create_user_process(LockRefPtr<Thread>& first_thread, StringView path, UserID uid, GroupID gid, NonnullOwnPtrVector<KString> arguments, NonnullOwnPtrVector<KString> environment, TTY* tty)
|
||||
ErrorOr<NonnullLockRefPtr<Process>> Process::try_create_user_process(LockRefPtr<Thread>& first_thread, StringView path, UserID uid, GroupID gid, Vector<NonnullOwnPtr<KString>> arguments, Vector<NonnullOwnPtr<KString>> environment, TTY* tty)
|
||||
{
|
||||
auto parts = path.split_view('/');
|
||||
if (arguments.is_empty()) {
|
||||
|
|
|
@ -192,7 +192,7 @@ public:
|
|||
}
|
||||
|
||||
static LockRefPtr<Process> create_kernel_process(LockRefPtr<Thread>& first_thread, NonnullOwnPtr<KString> name, void (*entry)(void*), void* entry_data = nullptr, u32 affinity = THREAD_AFFINITY_DEFAULT, RegisterProcess do_register = RegisterProcess::Yes);
|
||||
static ErrorOr<NonnullLockRefPtr<Process>> try_create_user_process(LockRefPtr<Thread>& first_thread, StringView path, UserID, GroupID, NonnullOwnPtrVector<KString> arguments, NonnullOwnPtrVector<KString> environment, TTY*);
|
||||
static ErrorOr<NonnullLockRefPtr<Process>> try_create_user_process(LockRefPtr<Thread>& first_thread, StringView path, UserID, GroupID, Vector<NonnullOwnPtr<KString>> arguments, Vector<NonnullOwnPtr<KString>> environment, TTY*);
|
||||
static void register_new(Process&);
|
||||
|
||||
~Process();
|
||||
|
@ -471,10 +471,10 @@ public:
|
|||
static constexpr size_t max_arguments_size = Thread::default_userspace_stack_size / 8;
|
||||
static constexpr size_t max_environment_size = Thread::default_userspace_stack_size / 8;
|
||||
static constexpr size_t max_auxiliary_size = Thread::default_userspace_stack_size / 8;
|
||||
NonnullOwnPtrVector<KString> const& arguments() const { return m_arguments; };
|
||||
NonnullOwnPtrVector<KString> const& environment() const { return m_environment; };
|
||||
Vector<NonnullOwnPtr<KString>> const& arguments() const { return m_arguments; };
|
||||
Vector<NonnullOwnPtr<KString>> const& environment() const { return m_environment; };
|
||||
|
||||
ErrorOr<void> exec(NonnullOwnPtr<KString> path, NonnullOwnPtrVector<KString> arguments, NonnullOwnPtrVector<KString> environment, Thread*& new_main_thread, InterruptsState& previous_interrupts_state, int recursion_depth = 0);
|
||||
ErrorOr<void> exec(NonnullOwnPtr<KString> path, Vector<NonnullOwnPtr<KString>> arguments, Vector<NonnullOwnPtr<KString>> environment, Thread*& new_main_thread, InterruptsState& previous_interrupts_state, int recursion_depth = 0);
|
||||
|
||||
ErrorOr<LoadResult> load(NonnullLockRefPtr<OpenFileDescription> main_program_description, LockRefPtr<OpenFileDescription> interpreter_description, const ElfW(Ehdr) & main_program_header);
|
||||
|
||||
|
@ -606,7 +606,7 @@ private:
|
|||
bool create_perf_events_buffer_if_needed();
|
||||
void delete_perf_events_buffer();
|
||||
|
||||
ErrorOr<void> do_exec(NonnullLockRefPtr<OpenFileDescription> main_program_description, NonnullOwnPtrVector<KString> arguments, NonnullOwnPtrVector<KString> environment, LockRefPtr<OpenFileDescription> interpreter_description, Thread*& new_main_thread, InterruptsState& previous_interrupts_state, const ElfW(Ehdr) & main_program_header);
|
||||
ErrorOr<void> do_exec(NonnullLockRefPtr<OpenFileDescription> main_program_description, Vector<NonnullOwnPtr<KString>> arguments, Vector<NonnullOwnPtr<KString>> environment, LockRefPtr<OpenFileDescription> interpreter_description, Thread*& new_main_thread, InterruptsState& previous_interrupts_state, const ElfW(Ehdr) & main_program_header);
|
||||
ErrorOr<FlatPtr> do_write(OpenFileDescription&, UserOrKernelBuffer const&, size_t, Optional<off_t> = {});
|
||||
|
||||
ErrorOr<FlatPtr> do_statvfs(FileSystem const& path, Custody const*, statvfs* buf);
|
||||
|
@ -846,8 +846,8 @@ private:
|
|||
|
||||
SpinlockProtected<RefPtr<Custody>, LockRank::None> m_current_directory;
|
||||
|
||||
NonnullOwnPtrVector<KString> m_arguments;
|
||||
NonnullOwnPtrVector<KString> m_environment;
|
||||
Vector<NonnullOwnPtr<KString>> m_arguments;
|
||||
Vector<NonnullOwnPtr<KString>> m_environment;
|
||||
|
||||
LockRefPtr<TTY> m_tty;
|
||||
|
||||
|
|
|
@ -43,16 +43,16 @@ struct LoadResult {
|
|||
static constexpr size_t auxiliary_vector_size = 15;
|
||||
static Array<ELF::AuxiliaryValue, auxiliary_vector_size> generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, UserID uid, UserID euid, GroupID gid, GroupID egid, StringView executable_path, Optional<Process::ScopedDescriptionAllocation> const& main_program_fd_allocation);
|
||||
|
||||
static bool validate_stack_size(NonnullOwnPtrVector<KString> const& arguments, NonnullOwnPtrVector<KString>& environment, Array<ELF::AuxiliaryValue, auxiliary_vector_size> const& auxiliary)
|
||||
static bool validate_stack_size(Vector<NonnullOwnPtr<KString>> const& arguments, Vector<NonnullOwnPtr<KString>>& environment, Array<ELF::AuxiliaryValue, auxiliary_vector_size> const& auxiliary)
|
||||
{
|
||||
size_t total_arguments_size = 0;
|
||||
size_t total_environment_size = 0;
|
||||
size_t total_auxiliary_size = 0;
|
||||
|
||||
for (auto const& a : arguments)
|
||||
total_arguments_size += a.length() + 1;
|
||||
total_arguments_size += a->length() + 1;
|
||||
for (auto const& e : environment)
|
||||
total_environment_size += e.length() + 1;
|
||||
total_environment_size += e->length() + 1;
|
||||
for (auto const& v : auxiliary) {
|
||||
if (!v.optional_string.is_empty())
|
||||
total_auxiliary_size += round_up_to_power_of_two(v.optional_string.length() + 1, sizeof(FlatPtr));
|
||||
|
@ -77,8 +77,8 @@ static bool validate_stack_size(NonnullOwnPtrVector<KString> const& arguments, N
|
|||
return true;
|
||||
}
|
||||
|
||||
static ErrorOr<FlatPtr> make_userspace_context_for_main_thread([[maybe_unused]] ThreadRegisters& regs, Memory::Region& region, NonnullOwnPtrVector<KString> const& arguments,
|
||||
NonnullOwnPtrVector<KString> const& environment, Array<ELF::AuxiliaryValue, auxiliary_vector_size> auxiliary_values)
|
||||
static ErrorOr<FlatPtr> make_userspace_context_for_main_thread([[maybe_unused]] ThreadRegisters& regs, Memory::Region& region, Vector<NonnullOwnPtr<KString>> const& arguments,
|
||||
Vector<NonnullOwnPtr<KString>> const& environment, Array<ELF::AuxiliaryValue, auxiliary_vector_size> auxiliary_values)
|
||||
{
|
||||
FlatPtr new_sp = region.range().end().get();
|
||||
|
||||
|
@ -108,13 +108,13 @@ static ErrorOr<FlatPtr> make_userspace_context_for_main_thread([[maybe_unused]]
|
|||
|
||||
Vector<FlatPtr> argv_entries;
|
||||
for (auto const& argument : arguments) {
|
||||
push_string_on_new_stack(argument.view());
|
||||
push_string_on_new_stack(argument->view());
|
||||
TRY(argv_entries.try_append(new_sp));
|
||||
}
|
||||
|
||||
Vector<FlatPtr> env_entries;
|
||||
for (auto const& variable : environment) {
|
||||
push_string_on_new_stack(variable.view());
|
||||
push_string_on_new_stack(variable->view());
|
||||
TRY(env_entries.try_append(new_sp));
|
||||
}
|
||||
|
||||
|
@ -471,7 +471,7 @@ void Process::clear_signal_handlers_for_exec()
|
|||
}
|
||||
}
|
||||
|
||||
ErrorOr<void> Process::do_exec(NonnullLockRefPtr<OpenFileDescription> main_program_description, NonnullOwnPtrVector<KString> arguments, NonnullOwnPtrVector<KString> environment,
|
||||
ErrorOr<void> Process::do_exec(NonnullLockRefPtr<OpenFileDescription> main_program_description, Vector<NonnullOwnPtr<KString>> arguments, Vector<NonnullOwnPtr<KString>> environment,
|
||||
LockRefPtr<OpenFileDescription> interpreter_description, Thread*& new_main_thread, InterruptsState& previous_interrupts_state, const ElfW(Ehdr) & main_program_header)
|
||||
{
|
||||
VERIFY(is_user_process());
|
||||
|
@ -746,12 +746,12 @@ static Array<ELF::AuxiliaryValue, auxiliary_vector_size> generate_auxiliary_vect
|
|||
} };
|
||||
}
|
||||
|
||||
static ErrorOr<NonnullOwnPtrVector<KString>> find_shebang_interpreter_for_executable(char const first_page[], size_t nread)
|
||||
static ErrorOr<Vector<NonnullOwnPtr<KString>>> find_shebang_interpreter_for_executable(char const first_page[], size_t nread)
|
||||
{
|
||||
int word_start = 2;
|
||||
size_t word_length = 0;
|
||||
if (nread > 2 && first_page[0] == '#' && first_page[1] == '!') {
|
||||
NonnullOwnPtrVector<KString> interpreter_words;
|
||||
Vector<NonnullOwnPtr<KString>> interpreter_words;
|
||||
|
||||
for (size_t i = 2; i < nread; ++i) {
|
||||
if (first_page[i] == '\n') {
|
||||
|
@ -851,7 +851,7 @@ ErrorOr<LockRefPtr<OpenFileDescription>> Process::find_elf_interpreter_for_execu
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ErrorOr<void> Process::exec(NonnullOwnPtr<KString> path, NonnullOwnPtrVector<KString> arguments, NonnullOwnPtrVector<KString> environment, Thread*& new_main_thread, InterruptsState& previous_interrupts_state, int recursion_depth)
|
||||
ErrorOr<void> Process::exec(NonnullOwnPtr<KString> path, Vector<NonnullOwnPtr<KString>> arguments, Vector<NonnullOwnPtr<KString>> environment, Thread*& new_main_thread, InterruptsState& previous_interrupts_state, int recursion_depth)
|
||||
{
|
||||
if (recursion_depth > 2) {
|
||||
dbgln("exec({}): SHENANIGANS! recursed too far trying to find #! interpreter", path);
|
||||
|
@ -886,8 +886,8 @@ ErrorOr<void> Process::exec(NonnullOwnPtr<KString> path, NonnullOwnPtrVector<KSt
|
|||
auto shebang_result = find_shebang_interpreter_for_executable(first_page, nread);
|
||||
if (!shebang_result.is_error()) {
|
||||
auto shebang_words = shebang_result.release_value();
|
||||
auto shebang_path = TRY(shebang_words.first().try_clone());
|
||||
arguments.ptr_at(0) = move(path);
|
||||
auto shebang_path = TRY(shebang_words.first()->try_clone());
|
||||
arguments[0] = move(path);
|
||||
TRY(arguments.try_prepend(move(shebang_words)));
|
||||
return exec(move(shebang_path), move(arguments), move(environment), new_main_thread, previous_interrupts_state, ++recursion_depth);
|
||||
}
|
||||
|
@ -949,10 +949,10 @@ ErrorOr<FlatPtr> Process::sys$execve(Userspace<Syscall::SC_execve_params const*>
|
|||
return {};
|
||||
};
|
||||
|
||||
NonnullOwnPtrVector<KString> arguments;
|
||||
Vector<NonnullOwnPtr<KString>> arguments;
|
||||
TRY(copy_user_strings(params.arguments, arguments));
|
||||
|
||||
NonnullOwnPtrVector<KString> environment;
|
||||
Vector<NonnullOwnPtr<KString>> environment;
|
||||
TRY(copy_user_strings(params.environment, environment));
|
||||
|
||||
TRY(exec(move(path), move(arguments), move(environment), new_main_thread, previous_interrupts_state));
|
||||
|
|
|
@ -456,21 +456,21 @@ void BrowserWindow::open_previous_tab()
|
|||
void BrowserWindow::enable_auto_color_scheme()
|
||||
{
|
||||
for (auto& tab : m_tabs) {
|
||||
tab.view().set_preferred_color_scheme(Web::CSS::PreferredColorScheme::Auto);
|
||||
tab->view().set_preferred_color_scheme(Web::CSS::PreferredColorScheme::Auto);
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserWindow::enable_light_color_scheme()
|
||||
{
|
||||
for (auto& tab : m_tabs) {
|
||||
tab.view().set_preferred_color_scheme(Web::CSS::PreferredColorScheme::Light);
|
||||
tab->view().set_preferred_color_scheme(Web::CSS::PreferredColorScheme::Light);
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserWindow::enable_dark_color_scheme()
|
||||
{
|
||||
for (auto& tab : m_tabs) {
|
||||
tab.view().set_preferred_color_scheme(Web::CSS::PreferredColorScheme::Dark);
|
||||
tab->view().set_preferred_color_scheme(Web::CSS::PreferredColorScheme::Dark);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ private:
|
|||
void debug_request(DeprecatedString const& request, DeprecatedString const& argument = "");
|
||||
|
||||
QTabWidget* m_tabs_container { nullptr };
|
||||
NonnullOwnPtrVector<Tab> m_tabs;
|
||||
Vector<NonnullOwnPtr<Tab>> m_tabs;
|
||||
Tab* m_current_tab { nullptr };
|
||||
|
||||
Browser::CookieJar& m_cookie_jar;
|
||||
|
|
|
@ -72,7 +72,7 @@ TEST_CASE(key_ordered_iteration)
|
|||
{
|
||||
constexpr auto amount = 10000;
|
||||
IntrusiveRBTree test;
|
||||
NonnullOwnPtrVector<IntrusiveTest> m_entries;
|
||||
Vector<NonnullOwnPtr<IntrusiveTest>> m_entries;
|
||||
Array<int, amount> keys {};
|
||||
|
||||
// generate random key order
|
||||
|
@ -105,7 +105,7 @@ TEST_CASE(key_ordered_iteration)
|
|||
TEST_CASE(clear)
|
||||
{
|
||||
IntrusiveRBTree test;
|
||||
NonnullOwnPtrVector<IntrusiveTest> m_entries;
|
||||
Vector<NonnullOwnPtr<IntrusiveTest>> m_entries;
|
||||
for (size_t i = 0; i < 1000; i++) {
|
||||
auto entry = make<IntrusiveTest>(i);
|
||||
test.insert(i, *entry);
|
||||
|
|
|
@ -288,7 +288,7 @@ TEST_CASE(nonnullownptrvector)
|
|||
struct Object {
|
||||
DeprecatedString string;
|
||||
};
|
||||
NonnullOwnPtrVector<Object> objects;
|
||||
Vector<NonnullOwnPtr<Object>> objects;
|
||||
|
||||
objects.append(make<Object>());
|
||||
EXPECT_EQ(objects.size(), 1u);
|
||||
|
|
|
@ -71,7 +71,7 @@ void ToolboxWidget::setup_tools()
|
|||
m_tools.append(move(tool));
|
||||
if (is_default_tool) {
|
||||
VERIFY(m_active_tool == nullptr);
|
||||
m_active_tool = &m_tools[m_tools.size() - 1];
|
||||
m_active_tool = m_tools[m_tools.size() - 1];
|
||||
action->set_checked(true);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
void for_each_tool(Callback callback)
|
||||
{
|
||||
for (auto& tool : m_tools)
|
||||
callback(tool);
|
||||
callback(*tool);
|
||||
}
|
||||
|
||||
Tool* active_tool() const { return m_active_tool; }
|
||||
|
@ -40,7 +40,7 @@ private:
|
|||
explicit ToolboxWidget();
|
||||
RefPtr<GUI::Toolbar> m_toolbar;
|
||||
GUI::ActionGroup m_action_group;
|
||||
NonnullOwnPtrVector<Tool> m_tools;
|
||||
Vector<NonnullOwnPtr<Tool>> m_tools;
|
||||
Tool* m_active_tool { nullptr };
|
||||
};
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ GUI::ModelIndex ProcessModel::index(int row, int column, GUI::ModelIndex const&
|
|||
if (!parent.is_valid()) {
|
||||
if (row >= static_cast<int>(m_processes.size()))
|
||||
return {};
|
||||
auto corresponding_thread = m_processes[row].main_thread();
|
||||
auto corresponding_thread = m_processes[row]->main_thread();
|
||||
if (!corresponding_thread.has_value())
|
||||
return {};
|
||||
return create_index(row, column, corresponding_thread.release_value().ptr());
|
||||
|
@ -368,8 +368,14 @@ int ProcessModel::thread_model_row(Thread const& thread) const
|
|||
{
|
||||
auto const& process = thread.current_state.process;
|
||||
// A process's main thread uses the global process index.
|
||||
if (process.pid == thread.current_state.pid)
|
||||
return m_processes.find_first_index(process).value_or(0);
|
||||
if (process.pid == thread.current_state.pid) {
|
||||
auto it = m_processes.find_if([&](auto& entry) {
|
||||
return entry.ptr() == &process;
|
||||
});
|
||||
if (it == m_processes.end())
|
||||
return 0;
|
||||
return it.index();
|
||||
}
|
||||
|
||||
return process.threads.find_first_index(thread).value_or(0);
|
||||
}
|
||||
|
@ -387,7 +393,15 @@ GUI::ModelIndex ProcessModel::parent_index(GUI::ModelIndex const& index) const
|
|||
if (!parent.main_thread().has_value())
|
||||
return {};
|
||||
|
||||
return create_index(m_processes.find_first_index(parent).release_value(), index.column(), parent.main_thread().value().ptr());
|
||||
auto process_index = [&]() -> size_t {
|
||||
auto it = m_processes.find_if([&](auto& entry) {
|
||||
return entry.ptr() == &parent;
|
||||
});
|
||||
if (it == m_processes.end())
|
||||
return 0;
|
||||
return it.index();
|
||||
}();
|
||||
return create_index(process_index, index.column(), parent.main_thread().value().ptr());
|
||||
}
|
||||
|
||||
Vector<GUI::ModelIndex> ProcessModel::matches(StringView searching, unsigned flags, GUI::ModelIndex const&)
|
||||
|
@ -444,7 +458,7 @@ void ProcessModel::update()
|
|||
auto const& process = all_processes.value().processes[i];
|
||||
NonnullOwnPtr<Process>* process_state = nullptr;
|
||||
for (size_t i = 0; i < m_processes.size(); ++i) {
|
||||
auto* other_process = &m_processes.ptr_at(i);
|
||||
auto* other_process = &m_processes[i];
|
||||
if ((*other_process)->pid == process.pid) {
|
||||
process_state = other_process;
|
||||
break;
|
||||
|
@ -452,7 +466,7 @@ void ProcessModel::update()
|
|||
}
|
||||
if (!process_state) {
|
||||
m_processes.append(make<Process>());
|
||||
process_state = &m_processes.ptr_at(m_processes.size() - 1);
|
||||
process_state = &m_processes.last();
|
||||
}
|
||||
(*process_state)->pid = process.pid;
|
||||
for (auto& thread : process.threads) {
|
||||
|
@ -508,8 +522,8 @@ void ProcessModel::update()
|
|||
}
|
||||
|
||||
for (auto& c : m_cpus) {
|
||||
c.total_cpu_percent = 0.0;
|
||||
c.total_cpu_percent_kernel = 0.0;
|
||||
c->total_cpu_percent = 0.0;
|
||||
c->total_cpu_percent_kernel = 0.0;
|
||||
}
|
||||
|
||||
Vector<int, 16> tids_to_remove;
|
||||
|
@ -526,8 +540,8 @@ void ProcessModel::update()
|
|||
thread.current_state.cpu_percent_kernel = total_time_scheduled_diff > 0 ? (float)((time_scheduled_diff_kernel * 1000) / total_time_scheduled_diff) / 10.0f : 0;
|
||||
if (it.value->current_state.pid != 0) {
|
||||
auto& cpu_info = m_cpus[thread.current_state.cpu];
|
||||
cpu_info.total_cpu_percent += thread.current_state.cpu_percent;
|
||||
cpu_info.total_cpu_percent_kernel += thread.current_state.cpu_percent_kernel;
|
||||
cpu_info->total_cpu_percent += thread.current_state.cpu_percent;
|
||||
cpu_info->total_cpu_percent_kernel += thread.current_state.cpu_percent_kernel;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -536,8 +550,8 @@ void ProcessModel::update()
|
|||
m_threads.remove(tid);
|
||||
for (size_t i = 0; i < m_processes.size(); ++i) {
|
||||
auto& process = m_processes[i];
|
||||
process.threads.remove_all_matching([&](auto const& thread) { return thread->current_state.tid == tid; });
|
||||
if (process.threads.size() == 0) {
|
||||
process->threads.remove_all_matching([&](auto const& thread) { return thread->current_state.tid == tid; });
|
||||
if (process->threads.size() == 0) {
|
||||
m_processes.remove(i);
|
||||
--i;
|
||||
}
|
||||
|
|
|
@ -85,10 +85,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
Function<void(NonnullOwnPtrVector<CpuInfo> const&)> on_cpu_info_change;
|
||||
Function<void(Vector<NonnullOwnPtr<CpuInfo>> const&)> on_cpu_info_change;
|
||||
Function<void(int process_count, int thread_count)> on_state_update;
|
||||
|
||||
NonnullOwnPtrVector<CpuInfo> const& cpus() const { return m_cpus; }
|
||||
Vector<NonnullOwnPtr<CpuInfo>> const& cpus() const { return m_cpus; }
|
||||
|
||||
private:
|
||||
ProcessModel();
|
||||
|
@ -243,8 +243,8 @@ private:
|
|||
|
||||
// The thread list contains the same threads as the Process structs.
|
||||
HashMap<int, NonnullRefPtr<Thread>> m_threads;
|
||||
NonnullOwnPtrVector<Process> m_processes;
|
||||
NonnullOwnPtrVector<CpuInfo> m_cpus;
|
||||
Vector<NonnullOwnPtr<Process>> m_processes;
|
||||
Vector<NonnullOwnPtr<CpuInfo>> m_cpus;
|
||||
RefPtr<Core::DeprecatedFile> m_proc_all;
|
||||
GUI::Icon m_kernel_process_icon;
|
||||
u64 m_total_time_scheduled { 0 };
|
||||
|
|
|
@ -594,11 +594,11 @@ void build_performance_tab(GUI::Widget& graphs_container)
|
|||
cpu_graphs.append(cpu_graph);
|
||||
}
|
||||
}
|
||||
ProcessModel::the().on_cpu_info_change = [cpu_graphs](NonnullOwnPtrVector<ProcessModel::CpuInfo> const& cpus) mutable {
|
||||
ProcessModel::the().on_cpu_info_change = [cpu_graphs](Vector<NonnullOwnPtr<ProcessModel::CpuInfo>> const& cpus) mutable {
|
||||
float sum_cpu = 0;
|
||||
for (size_t i = 0; i < cpus.size(); ++i) {
|
||||
cpu_graphs[i].add_value({ static_cast<size_t>(cpus[i].total_cpu_percent), static_cast<size_t>(cpus[i].total_cpu_percent_kernel) });
|
||||
sum_cpu += cpus[i].total_cpu_percent;
|
||||
cpu_graphs[i].add_value({ static_cast<size_t>(cpus[i]->total_cpu_percent), static_cast<size_t>(cpus[i]->total_cpu_percent_kernel) });
|
||||
sum_cpu += cpus[i]->total_cpu_percent;
|
||||
}
|
||||
float cpu_usage = sum_cpu / (float)cpus.size();
|
||||
statusbar->set_text(2, DeprecatedString::formatted("CPU usage: {}%", (int)roundf(cpu_usage)));
|
||||
|
|
|
@ -75,13 +75,13 @@ GUI::ModelIndex ClassViewModel::parent_index(const GUI::ModelIndex& index) const
|
|||
|
||||
if (parent->parent == nullptr) {
|
||||
for (size_t row = 0; row < m_root_scope.size(); row++) {
|
||||
if (m_root_scope.ptr_at(row).ptr() == parent)
|
||||
if (m_root_scope[row].ptr() == parent)
|
||||
return create_index(row, 0, parent);
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
for (size_t row = 0; row < parent->parent->children.size(); row++) {
|
||||
ClassViewNode* child_at_row = parent->parent->children.ptr_at(row).ptr();
|
||||
ClassViewNode* child_at_row = parent->parent->children[row].ptr();
|
||||
if (child_at_row == parent)
|
||||
return create_index(row, 0, parent);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ ClassViewModel::ClassViewModel()
|
|||
});
|
||||
}
|
||||
|
||||
static ClassViewNode& add_child_node(NonnullOwnPtrVector<ClassViewNode>& children, NonnullOwnPtr<ClassViewNode>&& node_ptr, ClassViewNode* parent, CodeComprehension::Declaration const* declaration)
|
||||
static ClassViewNode& add_child_node(Vector<NonnullOwnPtr<ClassViewNode>>& children, NonnullOwnPtr<ClassViewNode>&& node_ptr, ClassViewNode* parent, CodeComprehension::Declaration const* declaration)
|
||||
{
|
||||
node_ptr->parent = parent;
|
||||
node_ptr->declaration = declaration;
|
||||
|
@ -124,7 +124,7 @@ static ClassViewNode& add_child_node(NonnullOwnPtrVector<ClassViewNode>& childre
|
|||
},
|
||||
0, &inserted_index);
|
||||
|
||||
return children.at(inserted_index);
|
||||
return *children.at(inserted_index);
|
||||
}
|
||||
|
||||
void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl)
|
||||
|
@ -135,21 +135,21 @@ void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl)
|
|||
if (!scope_parts.is_empty()) {
|
||||
// Traverse declarations tree to the parent of 'decl'
|
||||
for (auto& node : m_root_scope) {
|
||||
if (node.name == scope_parts.first())
|
||||
parent = &node;
|
||||
if (node->name == scope_parts.first())
|
||||
parent = node;
|
||||
}
|
||||
|
||||
if (parent == nullptr) {
|
||||
m_root_scope.append(make<ClassViewNode>(scope_parts.first()));
|
||||
parent = &m_root_scope.last();
|
||||
parent = m_root_scope.last();
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < scope_parts.size(); ++i) {
|
||||
auto& scope = scope_parts[i];
|
||||
ClassViewNode* next { nullptr };
|
||||
for (auto& child : parent->children) {
|
||||
if (child.name == scope) {
|
||||
next = &child;
|
||||
if (child->name == scope) {
|
||||
next = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl)
|
|||
}
|
||||
}
|
||||
|
||||
NonnullOwnPtrVector<ClassViewNode>* children_of_parent = nullptr;
|
||||
Vector<NonnullOwnPtr<ClassViewNode>>* children_of_parent = nullptr;
|
||||
if (parent) {
|
||||
children_of_parent = &parent->children;
|
||||
} else {
|
||||
|
@ -172,10 +172,10 @@ void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl)
|
|||
|
||||
bool already_exists = false;
|
||||
for (auto& child : *children_of_parent) {
|
||||
if (child.name == decl.name) {
|
||||
if (child->name == decl.name) {
|
||||
already_exists = true;
|
||||
if (!child.declaration) {
|
||||
child.declaration = &decl;
|
||||
if (!child->declaration) {
|
||||
child->declaration = &decl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ private:
|
|||
struct ClassViewNode {
|
||||
StringView name;
|
||||
CodeComprehension::Declaration const* declaration { nullptr };
|
||||
NonnullOwnPtrVector<ClassViewNode> children;
|
||||
Vector<NonnullOwnPtr<ClassViewNode>> children;
|
||||
ClassViewNode* parent { nullptr };
|
||||
|
||||
explicit ClassViewNode(StringView name)
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
private:
|
||||
explicit ClassViewModel();
|
||||
void add_declaration(CodeComprehension::Declaration const&);
|
||||
NonnullOwnPtrVector<ClassViewNode> m_root_scope;
|
||||
Vector<NonnullOwnPtr<ClassViewNode>> m_root_scope;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -35,12 +35,12 @@ GUI::ModelIndex VariablesModel::parent_index(const GUI::ModelIndex& index) const
|
|||
|
||||
if (parent->parent == nullptr) {
|
||||
for (size_t row = 0; row < m_variables.size(); row++)
|
||||
if (m_variables.ptr_at(row).ptr() == parent)
|
||||
if (m_variables[row].ptr() == parent)
|
||||
return create_index(row, 0, parent);
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
for (size_t row = 0; row < parent->parent->members.size(); row++) {
|
||||
Debug::DebugInfo::VariableInfo* child_at_row = parent->parent->members.ptr_at(row).ptr();
|
||||
Debug::DebugInfo::VariableInfo* child_at_row = parent->parent->members[row].ptr();
|
||||
if (child_at_row == parent)
|
||||
return create_index(row, 0, parent);
|
||||
}
|
||||
|
|
|
@ -28,14 +28,14 @@ public:
|
|||
Debug::ProcessInspector& inspector() { return m_inspector; }
|
||||
|
||||
private:
|
||||
explicit VariablesModel(Debug::ProcessInspector& inspector, NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo>&& variables, PtraceRegisters const& regs)
|
||||
explicit VariablesModel(Debug::ProcessInspector& inspector, Vector<NonnullOwnPtr<Debug::DebugInfo::VariableInfo>>&& variables, PtraceRegisters const& regs)
|
||||
: m_variables(move(variables))
|
||||
, m_regs(regs)
|
||||
, m_inspector(inspector)
|
||||
{
|
||||
m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
NonnullOwnPtrVector<Debug::DebugInfo::VariableInfo> m_variables;
|
||||
Vector<NonnullOwnPtr<Debug::DebugInfo::VariableInfo>> m_variables;
|
||||
PtraceRegisters m_regs;
|
||||
|
||||
GUI::Icon m_variable_icon;
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
RemoteObjectPropertyModel& property_model();
|
||||
|
||||
RemoteObject* parent { nullptr };
|
||||
NonnullOwnPtrVector<RemoteObject> children;
|
||||
Vector<NonnullOwnPtr<RemoteObject>> children;
|
||||
|
||||
FlatPtr address { 0 };
|
||||
FlatPtr parent_address { 0 };
|
||||
|
|
|
@ -45,7 +45,7 @@ GUI::ModelIndex RemoteObjectGraphModel::parent_index(const GUI::ModelIndex& inde
|
|||
// NOTE: If the parent has no parent, it's a root, so we have to look among the remote roots.
|
||||
if (!remote_object.parent->parent) {
|
||||
for (size_t row = 0; row < m_process.roots().size(); ++row) {
|
||||
if (&m_process.roots()[row] == remote_object.parent)
|
||||
if (m_process.roots()[row] == remote_object.parent)
|
||||
return create_index(row, 0, remote_object.parent);
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -53,7 +53,7 @@ GUI::ModelIndex RemoteObjectGraphModel::parent_index(const GUI::ModelIndex& inde
|
|||
}
|
||||
|
||||
for (size_t row = 0; row < remote_object.parent->parent->children.size(); ++row) {
|
||||
if (&remote_object.parent->parent->children[row] == remote_object.parent)
|
||||
if (remote_object.parent->parent->children[row] == remote_object.parent)
|
||||
return create_index(row, 0, remote_object.parent);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ GUI::ModelIndex RemoteObjectPropertyModel::index(int row, int column, const GUI:
|
|||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
return &m_paths.last();
|
||||
return m_paths.last();
|
||||
};
|
||||
|
||||
if (!parent.is_valid()) {
|
||||
|
@ -176,16 +176,16 @@ JsonPath const* RemoteObjectPropertyModel::cached_path_at(int n, Vector<JsonPath
|
|||
JsonPath const* index_path = nullptr;
|
||||
int row_index = n;
|
||||
for (auto& path : m_paths) {
|
||||
if (path.size() != prefix.size() + 1)
|
||||
if (path->size() != prefix.size() + 1)
|
||||
continue;
|
||||
|
||||
for (size_t i = 0; i < prefix.size(); ++i) {
|
||||
if (path[i] != prefix[i])
|
||||
if ((*path)[i] != prefix[i])
|
||||
goto do_continue;
|
||||
}
|
||||
|
||||
if (row_index == 0) {
|
||||
index_path = &path;
|
||||
index_path = path;
|
||||
break;
|
||||
}
|
||||
--row_index;
|
||||
|
@ -198,15 +198,15 @@ JsonPath const* RemoteObjectPropertyModel::cached_path_at(int n, Vector<JsonPath
|
|||
JsonPath const* RemoteObjectPropertyModel::find_cached_path(Vector<JsonPathElement> const& path) const
|
||||
{
|
||||
for (auto& cpath : m_paths) {
|
||||
if (cpath.size() != path.size())
|
||||
if (cpath->size() != path.size())
|
||||
continue;
|
||||
|
||||
for (size_t i = 0; i < cpath.size(); ++i) {
|
||||
if (cpath[i] != path[i])
|
||||
for (size_t i = 0; i < cpath->size(); ++i) {
|
||||
if ((*cpath)[i] != path[i])
|
||||
goto do_continue;
|
||||
}
|
||||
|
||||
return &cpath;
|
||||
return cpath;
|
||||
do_continue:;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ private:
|
|||
JsonPath const* find_cached_path(Vector<JsonPathElement> const& path) const;
|
||||
|
||||
RemoteObject& m_object;
|
||||
mutable NonnullOwnPtrVector<JsonPath> m_paths;
|
||||
mutable Vector<NonnullOwnPtr<JsonPath>> m_paths;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void RemoteProcess::handle_get_all_objects_response(JsonObject const& response)
|
|||
// FIXME: It would be good if we didn't have to make a local copy of the array value here!
|
||||
auto& object_array = response.get_array("objects"sv).value();
|
||||
|
||||
NonnullOwnPtrVector<RemoteObject> remote_objects;
|
||||
Vector<NonnullOwnPtr<RemoteObject>> remote_objects;
|
||||
HashMap<FlatPtr, RemoteObject*> objects_by_address;
|
||||
|
||||
for (auto& value : object_array.values()) {
|
||||
|
@ -59,7 +59,7 @@ void RemoteProcess::handle_get_all_objects_response(JsonObject const& response)
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < remote_objects.size(); ++i) {
|
||||
auto& remote_object = remote_objects.ptr_at(i);
|
||||
auto& remote_object = remote_objects[i];
|
||||
auto* parent = objects_by_address.get(remote_object->parent_address).value_or(nullptr);
|
||||
if (!parent) {
|
||||
m_roots.append(move(remote_object));
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
DeprecatedString const& process_name() const { return m_process_name; }
|
||||
|
||||
RemoteObjectGraphModel& object_graph_model() { return *m_object_graph_model; }
|
||||
NonnullOwnPtrVector<RemoteObject> const& roots() const { return m_roots; }
|
||||
Vector<NonnullOwnPtr<RemoteObject>> const& roots() const { return m_roots; }
|
||||
|
||||
void set_inspected_object(FlatPtr);
|
||||
|
||||
|
@ -42,7 +42,7 @@ private:
|
|||
pid_t m_pid { -1 };
|
||||
DeprecatedString m_process_name;
|
||||
NonnullRefPtr<RemoteObjectGraphModel> m_object_graph_model;
|
||||
NonnullOwnPtrVector<RemoteObject> m_roots;
|
||||
Vector<NonnullOwnPtr<RemoteObject>> m_roots;
|
||||
RefPtr<InspectorServerClient> m_client;
|
||||
};
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
return Error::from_string_literal("Malformed profile (events is not an array)");
|
||||
auto const& perf_events = events_value.value();
|
||||
|
||||
NonnullOwnPtrVector<Process> all_processes;
|
||||
Vector<NonnullOwnPtr<Process>> all_processes;
|
||||
HashMap<pid_t, Process*> current_processes;
|
||||
Vector<Event> events;
|
||||
EventSerialNumber next_serial;
|
||||
|
@ -448,15 +448,15 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
|
|||
return Error::from_string_literal("No events captured (targeted process was never on CPU)");
|
||||
|
||||
quick_sort(all_processes, [](auto& a, auto& b) {
|
||||
if (a.pid == b.pid)
|
||||
return a.start_valid < b.start_valid;
|
||||
if (a->pid == b->pid)
|
||||
return a->start_valid < b->start_valid;
|
||||
|
||||
return a.pid < b.pid;
|
||||
return a->pid < b->pid;
|
||||
});
|
||||
|
||||
Vector<Process> processes;
|
||||
for (auto& it : all_processes)
|
||||
processes.append(move(it));
|
||||
processes.append(move(*it));
|
||||
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) Profile(move(processes), move(events)));
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
Emulator(DeprecatedString const& executable_path, Vector<StringView> const& arguments, Vector<DeprecatedString> const& environment);
|
||||
|
||||
void set_profiling_details(bool should_dump_profile, size_t instruction_interval, Stream* profile_stream, NonnullOwnPtrVector<DeprecatedString>* profiler_strings, Vector<int>* profiler_string_id_map)
|
||||
void set_profiling_details(bool should_dump_profile, size_t instruction_interval, Stream* profile_stream, Vector<NonnullOwnPtr<DeprecatedString>>* profiler_strings, Vector<int>* profiler_string_id_map)
|
||||
{
|
||||
m_is_profiling = should_dump_profile;
|
||||
m_profile_instruction_interval = instruction_interval;
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
}
|
||||
|
||||
Stream& profile_stream() { return *m_profile_stream; }
|
||||
NonnullOwnPtrVector<DeprecatedString>& profiler_strings() { return *m_profiler_strings; }
|
||||
Vector<NonnullOwnPtr<DeprecatedString>>& profiler_strings() { return *m_profiler_strings; }
|
||||
Vector<int>& profiler_string_id_map() { return *m_profiler_string_id_map; }
|
||||
|
||||
bool is_profiling() const { return m_is_profiling; }
|
||||
|
@ -296,7 +296,7 @@ private:
|
|||
|
||||
Stream* m_profile_stream { nullptr };
|
||||
Vector<int>* m_profiler_string_id_map { nullptr };
|
||||
NonnullOwnPtrVector<DeprecatedString>* m_profiler_strings { nullptr };
|
||||
Vector<NonnullOwnPtr<DeprecatedString>>* m_profiler_strings { nullptr };
|
||||
|
||||
bool m_is_profiling { false };
|
||||
size_t m_profile_instruction_interval { 0 };
|
||||
|
|
|
@ -144,7 +144,7 @@ private:
|
|||
Region* m_page_to_region_map[786432] = { nullptr };
|
||||
|
||||
OwnPtr<Region> m_tls_region;
|
||||
NonnullOwnPtrVector<Region> m_regions;
|
||||
Vector<NonnullOwnPtr<Region>> m_regions;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ int main(int argc, char** argv, char** env)
|
|||
profile_dump_path = DeprecatedString::formatted("{}.{}.profile", LexicalPath(executable_path).basename(), getpid());
|
||||
|
||||
OwnPtr<Stream> profile_stream;
|
||||
OwnPtr<NonnullOwnPtrVector<DeprecatedString>> profile_strings;
|
||||
OwnPtr<Vector<NonnullOwnPtr<DeprecatedString>>> profile_strings;
|
||||
OwnPtr<Vector<int>> profile_string_id_map;
|
||||
|
||||
if (dump_profile) {
|
||||
|
@ -67,7 +67,7 @@ int main(int argc, char** argv, char** env)
|
|||
return 1;
|
||||
}
|
||||
profile_stream = profile_stream_or_error.release_value();
|
||||
profile_strings = make<NonnullOwnPtrVector<DeprecatedString>>();
|
||||
profile_strings = make<Vector<NonnullOwnPtr<DeprecatedString>>>();
|
||||
profile_string_id_map = make<Vector<int>>();
|
||||
|
||||
profile_stream->write_entire_buffer(R"({"events":[)"sv.bytes()).release_value_but_fixme_should_propagate_errors();
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
void for_each_pattern(Callback callback)
|
||||
{
|
||||
for (auto& pattern : m_patterns)
|
||||
callback(pattern);
|
||||
callback(*pattern);
|
||||
}
|
||||
|
||||
void run_generation();
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
Board::RowAndColumn m_last_cell_toggled {};
|
||||
Board::RowAndColumn m_last_cell_hovered {};
|
||||
Pattern* m_selected_pattern { nullptr };
|
||||
NonnullOwnPtrVector<Pattern> m_patterns;
|
||||
Vector<NonnullOwnPtr<Pattern>> m_patterns;
|
||||
|
||||
NonnullOwnPtr<Board> m_board;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void Inspector::set_registers(PtraceRegisters const&) {};
|
|||
void Inspector::for_each_loaded_library(Function<IterationDecision(Debug::LoadedLibrary const&)> func) const
|
||||
{
|
||||
for (auto& library : m_loaded_libraries) {
|
||||
if (func(library) == IterationDecision::Break)
|
||||
if (func(*library) == IterationDecision::Break)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ private:
|
|||
|
||||
NonnullOwnPtr<Reader> m_reader;
|
||||
|
||||
NonnullOwnPtrVector<Debug::LoadedLibrary> m_loaded_libraries;
|
||||
Vector<NonnullOwnPtr<Debug::LoadedLibrary>> m_loaded_libraries;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -160,9 +160,9 @@ Optional<DebugInfo::SourcePositionAndAddress> DebugInfo::get_address_from_source
|
|||
return result;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtrVector<DebugInfo::VariableInfo>> DebugInfo::get_variables_in_current_scope(PtraceRegisters const& regs) const
|
||||
ErrorOr<Vector<NonnullOwnPtr<DebugInfo::VariableInfo>>> DebugInfo::get_variables_in_current_scope(PtraceRegisters const& regs) const
|
||||
{
|
||||
NonnullOwnPtrVector<DebugInfo::VariableInfo> variables;
|
||||
Vector<NonnullOwnPtr<DebugInfo::VariableInfo>> variables;
|
||||
|
||||
// TODO: We can store the scopes in a better data structure
|
||||
for (auto const& scope : m_scopes) {
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
Dwarf::EntryTag type_tag;
|
||||
OwnPtr<VariableInfo> type;
|
||||
NonnullOwnPtrVector<VariableInfo> members;
|
||||
Vector<NonnullOwnPtr<VariableInfo>> members;
|
||||
VariableInfo* parent { nullptr };
|
||||
Vector<u32> dimension_sizes;
|
||||
|
||||
|
@ -90,7 +90,7 @@ public:
|
|||
Vector<Dwarf::DIE> dies_of_variables;
|
||||
};
|
||||
|
||||
ErrorOr<NonnullOwnPtrVector<VariableInfo>> get_variables_in_current_scope(PtraceRegisters const&) const;
|
||||
ErrorOr<Vector<NonnullOwnPtr<VariableInfo>>> get_variables_in_current_scope(PtraceRegisters const&) const;
|
||||
|
||||
Optional<SourcePosition> get_source_position(FlatPtr address) const;
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
ReadonlyBytes m_debug_addr_data;
|
||||
ReadonlyBytes m_debug_ranges_data;
|
||||
|
||||
NonnullOwnPtrVector<Dwarf::CompilationUnit> m_compilation_units;
|
||||
Vector<NonnullOwnPtr<Dwarf::CompilationUnit>> m_compilation_units;
|
||||
|
||||
struct DIERange {
|
||||
FlatPtr start_address { 0 };
|
||||
|
@ -93,7 +93,7 @@ template<typename Callback>
|
|||
ErrorOr<void> DwarfInfo::for_each_compilation_unit(Callback callback) const
|
||||
{
|
||||
for (auto const& unit : m_compilation_units) {
|
||||
TRY(callback(unit));
|
||||
TRY(callback(*unit));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -243,11 +243,11 @@ void CommandPalette::collect_actions(GUI::Window& parent_window)
|
|||
};
|
||||
|
||||
Function<void(Menu&)> collect_actions_from_menu = [&](Menu& menu) {
|
||||
for (auto menu_item : menu.items()) {
|
||||
if (menu_item.submenu())
|
||||
collect_actions_from_menu(*menu_item.submenu());
|
||||
for (auto& menu_item : menu.items()) {
|
||||
if (menu_item->submenu())
|
||||
collect_actions_from_menu(*menu_item->submenu());
|
||||
|
||||
auto* action = menu_item.action();
|
||||
auto* action = menu_item->action();
|
||||
if (should_show_action(action))
|
||||
actions.set(*action);
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ void EditingEngine::move_one_left()
|
|||
m_editor->set_cursor(m_editor->cursor().line(), new_column);
|
||||
} else if (m_editor->cursor().line() > 0) {
|
||||
auto new_line = m_editor->cursor().line() - 1;
|
||||
auto new_column = m_editor->lines()[new_line].length();
|
||||
auto new_column = m_editor->lines()[new_line]->length();
|
||||
m_editor->set_cursor(new_line, new_column);
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ void EditingEngine::move_to_first_line()
|
|||
|
||||
void EditingEngine::move_to_last_line()
|
||||
{
|
||||
m_editor->set_cursor(m_editor->line_count() - 1, m_editor->lines()[m_editor->line_count() - 1].length());
|
||||
m_editor->set_cursor(m_editor->line_count() - 1, m_editor->lines()[m_editor->line_count() - 1]->length());
|
||||
};
|
||||
|
||||
void EditingEngine::get_selection_line_boundaries(Badge<MoveLineUpOrDownCommand>, size_t& first_line, size_t& last_line)
|
||||
|
|
|
@ -33,7 +33,7 @@ ModelIndex FileSystemModel::Node::index(int column) const
|
|||
if (!m_parent)
|
||||
return {};
|
||||
for (size_t row = 0; row < m_parent->m_children.size(); ++row) {
|
||||
if (&m_parent->m_children[row] == this)
|
||||
if (m_parent->m_children[row] == this)
|
||||
return m_model.create_index(row, column, const_cast<Node*>(this));
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -111,8 +111,8 @@ void FileSystemModel::Node::traverse_if_needed()
|
|||
}
|
||||
quick_sort(child_names);
|
||||
|
||||
NonnullOwnPtrVector<Node> directory_children;
|
||||
NonnullOwnPtrVector<Node> file_children;
|
||||
Vector<NonnullOwnPtr<Node>> directory_children;
|
||||
Vector<NonnullOwnPtr<Node>> file_children;
|
||||
|
||||
for (auto& child_name : child_names) {
|
||||
auto maybe_child = create_child(child_name);
|
||||
|
@ -229,7 +229,7 @@ Optional<FileSystemModel::Node const&> FileSystemModel::node_for_path(Deprecated
|
|||
resolved_path = path;
|
||||
LexicalPath lexical_path(resolved_path);
|
||||
|
||||
Node const* node = m_root->m_parent_of_root ? &m_root->m_children.first() : m_root;
|
||||
Node const* node = m_root->m_parent_of_root ? m_root->m_children.first() : m_root.ptr();
|
||||
if (lexical_path.string() == "/")
|
||||
return *node;
|
||||
|
||||
|
@ -238,9 +238,9 @@ Optional<FileSystemModel::Node const&> FileSystemModel::node_for_path(Deprecated
|
|||
auto& part = parts[i];
|
||||
bool found = false;
|
||||
for (auto& child : node->m_children) {
|
||||
if (child.name == part) {
|
||||
const_cast<Node&>(child).reify_if_needed();
|
||||
node = &child;
|
||||
if (child->name == part) {
|
||||
const_cast<Node&>(*child).reify_if_needed();
|
||||
node = child;
|
||||
found = true;
|
||||
if (i == parts.size() - 1)
|
||||
return *node;
|
||||
|
@ -494,7 +494,7 @@ ModelIndex FileSystemModel::index(int row, int column, ModelIndex const& parent)
|
|||
const_cast<Node&>(node).reify_if_needed();
|
||||
if (static_cast<size_t>(row) >= node.m_children.size())
|
||||
return {};
|
||||
return create_index(row, column, &node.m_children[row]);
|
||||
return create_index(row, column, node.m_children[row].ptr());
|
||||
}
|
||||
|
||||
ModelIndex FileSystemModel::parent_index(ModelIndex const& index) const
|
||||
|
@ -801,9 +801,9 @@ Vector<ModelIndex> FileSystemModel::matches(StringView searching, unsigned flags
|
|||
node.reify_if_needed();
|
||||
Vector<ModelIndex> found_indices;
|
||||
for (auto& child : node.m_children) {
|
||||
if (string_matches(child.name, searching, flags)) {
|
||||
const_cast<Node&>(child).reify_if_needed();
|
||||
found_indices.append(child.index(Column::Name));
|
||||
if (string_matches(child->name, searching, flags)) {
|
||||
const_cast<Node&>(*child).reify_if_needed();
|
||||
found_indices.append(child->index(Column::Name));
|
||||
if (flags & FirstMatchOnly)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
FileSystemModel& m_model;
|
||||
|
||||
Node* m_parent { nullptr };
|
||||
NonnullOwnPtrVector<Node> m_children;
|
||||
Vector<NonnullOwnPtr<Node>> m_children;
|
||||
bool m_has_traversed { false };
|
||||
|
||||
bool m_selected { false };
|
||||
|
|
|
@ -68,7 +68,7 @@ void Menu::add_action(NonnullRefPtr<Action> action)
|
|||
void Menu::remove_all_actions()
|
||||
{
|
||||
for (auto& item : m_items) {
|
||||
ConnectionToWindowServer::the().async_remove_menu_item(m_menu_id, item.identifier());
|
||||
ConnectionToWindowServer::the().async_remove_menu_item(m_menu_id, item->identifier());
|
||||
}
|
||||
m_items.clear();
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ int Menu::realize_menu(RefPtr<Action> default_action)
|
|||
m_current_default_action = default_action;
|
||||
|
||||
for (size_t i = 0; i < m_items.size(); ++i) {
|
||||
realize_menu_item(m_items[i], i);
|
||||
realize_menu_item(*m_items[i], i);
|
||||
}
|
||||
|
||||
all_menus().set(m_menu_id, this);
|
||||
|
@ -168,14 +168,14 @@ Action* Menu::action_at(size_t index)
|
|||
{
|
||||
if (index >= m_items.size())
|
||||
return nullptr;
|
||||
return m_items[index].action();
|
||||
return m_items[index]->action();
|
||||
}
|
||||
|
||||
void Menu::set_children_actions_enabled(bool enabled)
|
||||
{
|
||||
for (auto& item : m_items) {
|
||||
if (item.action())
|
||||
item.action()->set_enabled(enabled);
|
||||
if (item->action())
|
||||
item->action()->set_enabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
bool is_visible() const { return m_visible; }
|
||||
|
||||
NonnullOwnPtrVector<MenuItem> const& items() const { return m_items; }
|
||||
Vector<NonnullOwnPtr<MenuItem>> const& items() const { return m_items; }
|
||||
|
||||
private:
|
||||
friend class Menubar;
|
||||
|
@ -77,7 +77,7 @@ private:
|
|||
int m_menu_id { -1 };
|
||||
DeprecatedString m_name;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
NonnullOwnPtrVector<MenuItem> m_items;
|
||||
Vector<NonnullOwnPtr<MenuItem>> m_items;
|
||||
WeakPtr<Action> m_current_default_action;
|
||||
bool m_visible { false };
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void RegularEditingEngine::sort_selected_lines()
|
|||
auto end = lines.begin() + (int)last_line + 1;
|
||||
|
||||
quick_sort(start, end, [](auto& a, auto& b) {
|
||||
return strcmp_utf32(a.code_points(), b.code_points(), min(a.length(), b.length())) < 0;
|
||||
return strcmp_utf32(a->code_points(), b->code_points(), min(a->length(), b->length())) < 0;
|
||||
});
|
||||
|
||||
m_editor->did_change();
|
||||
|
|
|
@ -462,7 +462,7 @@ void TextDocument::update_regex_matches(StringView needle)
|
|||
Vector<RegexStringView> views;
|
||||
|
||||
for (size_t line = 0; line < m_lines.size(); ++line) {
|
||||
views.append(m_lines.at(line).view());
|
||||
views.append(m_lines[line]->view());
|
||||
}
|
||||
re.search(views, m_regex_result);
|
||||
m_regex_needs_update = false;
|
||||
|
|
|
@ -70,15 +70,15 @@ public:
|
|||
virtual ~TextDocument() = default;
|
||||
|
||||
size_t line_count() const { return m_lines.size(); }
|
||||
TextDocumentLine const& line(size_t line_index) const { return m_lines[line_index]; }
|
||||
TextDocumentLine& line(size_t line_index) { return m_lines[line_index]; }
|
||||
TextDocumentLine const& line(size_t line_index) const { return *m_lines[line_index]; }
|
||||
TextDocumentLine& line(size_t line_index) { return *m_lines[line_index]; }
|
||||
|
||||
void set_spans(u32 span_collection_index, Vector<TextDocumentSpan> spans);
|
||||
|
||||
bool set_text(StringView, AllowCallback = AllowCallback::Yes);
|
||||
|
||||
NonnullOwnPtrVector<TextDocumentLine> const& lines() const { return m_lines; }
|
||||
NonnullOwnPtrVector<TextDocumentLine>& lines() { return m_lines; }
|
||||
Vector<NonnullOwnPtr<TextDocumentLine>> const& lines() const { return m_lines; }
|
||||
Vector<NonnullOwnPtr<TextDocumentLine>>& lines() { return m_lines; }
|
||||
|
||||
bool has_spans() const { return !m_spans.is_empty(); }
|
||||
Vector<TextDocumentSpan>& spans() { return m_spans; }
|
||||
|
@ -163,7 +163,7 @@ protected:
|
|||
private:
|
||||
void merge_span_collections();
|
||||
|
||||
NonnullOwnPtrVector<TextDocumentLine> m_lines;
|
||||
Vector<NonnullOwnPtr<TextDocumentLine>> m_lines;
|
||||
HashMap<u32, Vector<TextDocumentSpan>> m_span_collections;
|
||||
Vector<TextDocumentSpan> m_spans;
|
||||
Vector<TextDocumentFoldingRegion> m_folding_regions;
|
||||
|
|
|
@ -133,8 +133,8 @@ void TextEditor::update_content_size()
|
|||
int content_width = 0;
|
||||
int content_height = 0;
|
||||
for (auto& line : m_line_visual_data) {
|
||||
content_width = max(line.visual_rect.width(), content_width);
|
||||
content_height += line.visual_rect.height();
|
||||
content_width = max(line->visual_rect.width(), content_width);
|
||||
content_height += line->visual_rect.height();
|
||||
}
|
||||
content_width += m_horizontal_content_padding * 2;
|
||||
if (is_right_text_alignment(m_text_alignment))
|
||||
|
@ -167,7 +167,7 @@ TextPosition TextEditor::text_position_at_content_position(Gfx::IntPoint content
|
|||
if (!document().line_is_visible(i))
|
||||
continue;
|
||||
|
||||
auto& rect = m_line_visual_data[i].visual_rect;
|
||||
auto& rect = m_line_visual_data[i]->visual_rect;
|
||||
if (position.y() >= rect.top() && position.y() <= rect.bottom()) {
|
||||
line_index = i;
|
||||
break;
|
||||
|
@ -634,7 +634,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
first_visual_line_with_selection = visual_line_containing(line_index, selection.start().column());
|
||||
|
||||
if (selection.end().line() > line_index)
|
||||
last_visual_line_with_selection = m_line_visual_data[line_index].visual_lines.size();
|
||||
last_visual_line_with_selection = m_line_visual_data[line_index]->visual_lines.size();
|
||||
else
|
||||
last_visual_line_with_selection = visual_line_containing(line_index, selection.end().column());
|
||||
}
|
||||
|
@ -1441,7 +1441,7 @@ Gfx::IntRect TextEditor::line_content_rect(size_t line_index) const
|
|||
line_rect.center_vertically_within({ {}, frame_inner_rect().size() });
|
||||
return line_rect;
|
||||
}
|
||||
return m_line_visual_data[line_index].visual_rect;
|
||||
return m_line_visual_data[line_index]->visual_rect;
|
||||
}
|
||||
|
||||
void TextEditor::set_cursor_and_focus_line(size_t line, size_t column)
|
||||
|
@ -1451,8 +1451,8 @@ void TextEditor::set_cursor_and_focus_line(size_t line, size_t column)
|
|||
if (line > 1 && line < index_max) {
|
||||
int headroom = frame_inner_rect().height() / 3;
|
||||
do {
|
||||
auto line_data = m_line_visual_data[line];
|
||||
headroom -= line_data.visual_rect.height();
|
||||
auto const& line_data = m_line_visual_data[line];
|
||||
headroom -= line_data->visual_rect.height();
|
||||
line--;
|
||||
} while (line > 0 && headroom > 0);
|
||||
|
||||
|
@ -1481,8 +1481,8 @@ void TextEditor::set_cursor(TextPosition const& a_position)
|
|||
if (position.line() >= line_count())
|
||||
position.set_line(line_count() - 1);
|
||||
|
||||
if (position.column() > lines()[position.line()].length())
|
||||
position.set_column(lines()[position.line()].length());
|
||||
if (position.column() > lines()[position.line()]->length())
|
||||
position.set_column(lines()[position.line()]->length());
|
||||
|
||||
if (m_cursor != position && is_visual_data_up_to_date()) {
|
||||
// NOTE: If the old cursor is no longer valid, repaint everything just in case.
|
||||
|
@ -1972,8 +1972,8 @@ void TextEditor::recompute_all_visual_lines()
|
|||
auto folded_region_iterator = folded_regions.begin();
|
||||
for (size_t line_index = 0; line_index < line_count(); ++line_index) {
|
||||
recompute_visual_lines(line_index, folded_region_iterator);
|
||||
m_line_visual_data[line_index].visual_rect.set_y(y_offset);
|
||||
y_offset += m_line_visual_data[line_index].visual_rect.height();
|
||||
m_line_visual_data[line_index]->visual_rect.set_y(y_offset);
|
||||
y_offset += m_line_visual_data[line_index]->visual_rect.height();
|
||||
}
|
||||
|
||||
update_content_size();
|
||||
|
@ -2008,7 +2008,7 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
|
|||
size_t line_width_so_far = 0;
|
||||
|
||||
auto& visual_data = m_line_visual_data[line_index];
|
||||
visual_data.visual_lines.clear_with_capacity();
|
||||
visual_data->visual_lines.clear_with_capacity();
|
||||
|
||||
auto available_width = visible_text_rect_in_inner_coordinates().width();
|
||||
auto glyph_spacing = font().glyph_spacing();
|
||||
|
@ -2034,7 +2034,7 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
|
|||
|
||||
if (line_width_so_far + glyph_width + glyph_spacing > available_width) {
|
||||
auto start_of_next_visual_line = line.view().iterator_offset(it_before_computing_glyph_width);
|
||||
visual_data.visual_lines.append(line.view().substring_view(start_of_visual_line, start_of_next_visual_line - start_of_visual_line));
|
||||
visual_data->visual_lines.append(line.view().substring_view(start_of_visual_line, start_of_next_visual_line - start_of_visual_line));
|
||||
line_width_so_far = 0;
|
||||
start_of_visual_line = start_of_next_visual_line;
|
||||
}
|
||||
|
@ -2042,7 +2042,7 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
|
|||
line_width_so_far += glyph_width + glyph_spacing;
|
||||
}
|
||||
|
||||
visual_data.visual_lines.append(line.view().substring_view(start_of_visual_line, line.view().length() - start_of_visual_line));
|
||||
visual_data->visual_lines.append(line.view().substring_view(start_of_visual_line, line.view().length() - start_of_visual_line));
|
||||
};
|
||||
|
||||
auto wrap_visual_lines_at_words = [&]() {
|
||||
|
@ -2057,7 +2057,7 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
|
|||
auto word_width = font().width(word);
|
||||
|
||||
if (line_width_so_far + word_width + glyph_spacing > available_width) {
|
||||
visual_data.visual_lines.append(line.view().substring_view(start_of_visual_line, last_boundary - start_of_visual_line));
|
||||
visual_data->visual_lines.append(line.view().substring_view(start_of_visual_line, last_boundary - start_of_visual_line));
|
||||
line_width_so_far = 0;
|
||||
start_of_visual_line = last_boundary;
|
||||
}
|
||||
|
@ -2068,13 +2068,13 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
|
|||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
visual_data.visual_lines.append(line.view().substring_view(start_of_visual_line, line.view().length() - start_of_visual_line));
|
||||
visual_data->visual_lines.append(line.view().substring_view(start_of_visual_line, line.view().length() - start_of_visual_line));
|
||||
};
|
||||
|
||||
if (line_is_visible) {
|
||||
switch (wrapping_mode()) {
|
||||
case WrappingMode::NoWrap:
|
||||
visual_data.visual_lines.append(line.view());
|
||||
visual_data->visual_lines.append(line.view());
|
||||
break;
|
||||
case WrappingMode::WrapAnywhere:
|
||||
wrap_visual_lines_anywhere();
|
||||
|
@ -2086,9 +2086,9 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
|
|||
}
|
||||
|
||||
if (is_wrapping_enabled())
|
||||
visual_data.visual_rect = { m_horizontal_content_padding, 0, available_width, static_cast<int>(visual_data.visual_lines.size()) * line_height() };
|
||||
visual_data->visual_rect = { m_horizontal_content_padding, 0, available_width, static_cast<int>(visual_data->visual_lines.size()) * line_height() };
|
||||
else
|
||||
visual_data.visual_rect = { m_horizontal_content_padding, 0, text_width_for_font(line.view(), font()), line_height() };
|
||||
visual_data->visual_rect = { m_horizontal_content_padding, 0, text_width_for_font(line.view(), font()), line_height() };
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
|
@ -2100,10 +2100,10 @@ void TextEditor::for_each_visual_line(size_t line_index, Callback callback) cons
|
|||
auto& line = document().line(line_index);
|
||||
auto& visual_data = m_line_visual_data[line_index];
|
||||
|
||||
for (auto visual_line_view : visual_data.visual_lines) {
|
||||
for (auto visual_line_view : visual_data->visual_lines) {
|
||||
Gfx::IntRect visual_line_rect {
|
||||
visual_data.visual_rect.x(),
|
||||
visual_data.visual_rect.y() + ((int)visual_line_index * line_height()),
|
||||
visual_data->visual_rect.x(),
|
||||
visual_data->visual_rect.y() + ((int)visual_line_index * line_height()),
|
||||
text_width_for_font(visual_line_view, font()) + font().glyph_spacing(),
|
||||
line_height()
|
||||
};
|
||||
|
@ -2115,7 +2115,7 @@ void TextEditor::for_each_visual_line(size_t line_index, Callback callback) cons
|
|||
visual_line_rect.translate_by(icon_size() + icon_padding(), 0);
|
||||
}
|
||||
size_t start_of_line = visual_line_view.code_points() - line.code_points();
|
||||
if (callback(visual_line_rect, visual_line_view, start_of_line, visual_line_index == visual_data.visual_lines.size() - 1) == IterationDecision::Break)
|
||||
if (callback(visual_line_rect, visual_line_view, start_of_line, visual_line_index == visual_data->visual_lines.size() - 1) == IterationDecision::Break)
|
||||
break;
|
||||
++visual_line_index;
|
||||
}
|
||||
|
|
|
@ -121,8 +121,8 @@ public:
|
|||
size_t line_count() const { return document().line_count(); }
|
||||
TextDocumentLine& line(size_t index) { return document().line(index); }
|
||||
TextDocumentLine const& line(size_t index) const { return document().line(index); }
|
||||
NonnullOwnPtrVector<TextDocumentLine>& lines() { return document().lines(); }
|
||||
NonnullOwnPtrVector<TextDocumentLine> const& lines() const { return document().lines(); }
|
||||
Vector<NonnullOwnPtr<TextDocumentLine>>& lines() { return document().lines(); }
|
||||
Vector<NonnullOwnPtr<TextDocumentLine>> const& lines() const { return document().lines(); }
|
||||
int line_height() const;
|
||||
TextPosition cursor() const { return m_cursor; }
|
||||
TextRange normalized_selection() const { return m_selection.normalized(); }
|
||||
|
@ -432,7 +432,7 @@ private:
|
|||
Gfx::IntRect visual_rect;
|
||||
};
|
||||
|
||||
NonnullOwnPtrVector<LineVisualData> m_line_visual_data;
|
||||
Vector<NonnullOwnPtr<LineVisualData>> m_line_visual_data;
|
||||
|
||||
OwnPtr<Syntax::Highlighter> m_highlighter;
|
||||
OwnPtr<AutocompleteProvider> m_autocomplete_provider;
|
||||
|
|
|
@ -111,7 +111,7 @@ ErrorOr<NonnullRefPtr<GUI::Button>> Toolbar::try_add_action(Action& action)
|
|||
item->widget->set_fixed_size(m_button_size, m_button_size);
|
||||
|
||||
m_items.unchecked_append(move(item));
|
||||
return *static_cast<Button*>(m_items.last().widget.ptr());
|
||||
return *static_cast<Button*>(m_items.last()->widget.ptr());
|
||||
}
|
||||
|
||||
GUI::Button& Toolbar::add_action(Action& action)
|
||||
|
@ -196,12 +196,12 @@ ErrorOr<void> Toolbar::update_overflow_menu()
|
|||
|
||||
for (size_t i = 0; i < m_items.size() - 1; ++i) {
|
||||
auto& item = m_items.at(i);
|
||||
auto item_size = is_horizontal ? item.widget->width() : item.widget->height();
|
||||
auto item_size = is_horizontal ? item->widget->width() : item->widget->height();
|
||||
if (position + item_size + margin > toolbar_size) {
|
||||
marginal_index = i;
|
||||
break;
|
||||
}
|
||||
item.widget->set_visible(true);
|
||||
item->widget->set_visible(true);
|
||||
position += item_size + spacing;
|
||||
}
|
||||
|
||||
|
@ -216,10 +216,10 @@ ErrorOr<void> Toolbar::update_overflow_menu()
|
|||
if (marginal_index.value() > 0) {
|
||||
for (size_t i = marginal_index.value() - 1; i > 0; --i) {
|
||||
auto& item = m_items.at(i);
|
||||
auto item_size = is_horizontal ? item.widget->width() : item.widget->height();
|
||||
auto item_size = is_horizontal ? item->widget->width() : item->widget->height();
|
||||
if (position + m_button_size + spacing + margin <= toolbar_size)
|
||||
break;
|
||||
item.widget->set_visible(false);
|
||||
item->widget->set_visible(false);
|
||||
position -= item_size + spacing;
|
||||
marginal_index = i;
|
||||
}
|
||||
|
@ -228,9 +228,9 @@ ErrorOr<void> Toolbar::update_overflow_menu()
|
|||
if (m_grouped) {
|
||||
for (size_t i = marginal_index.value(); i > 0; --i) {
|
||||
auto& item = m_items.at(i);
|
||||
if (item.type == Item::Type::Separator)
|
||||
if (item->type == Item::Type::Separator)
|
||||
break;
|
||||
item.widget->set_visible(false);
|
||||
item->widget->set_visible(false);
|
||||
marginal_index = i;
|
||||
}
|
||||
}
|
||||
|
@ -247,17 +247,17 @@ ErrorOr<void> Toolbar::update_overflow_menu()
|
|||
auto& item = m_items.at(i);
|
||||
Item* peek_item;
|
||||
if (i > 0) {
|
||||
peek_item = &m_items.at(i - 1);
|
||||
peek_item = m_items[i - 1];
|
||||
if (peek_item->type == Item::Type::Separator)
|
||||
peek_item->widget->set_visible(false);
|
||||
}
|
||||
if (i < m_items.size() - 1) {
|
||||
item.widget->set_visible(false);
|
||||
peek_item = &m_items.at(i + 1);
|
||||
if (item.action)
|
||||
TRY(m_overflow_menu->try_add_action(*item.action));
|
||||
item->widget->set_visible(false);
|
||||
peek_item = m_items[i + 1];
|
||||
if (item->action)
|
||||
TRY(m_overflow_menu->try_add_action(*item->action));
|
||||
}
|
||||
if (item.action && peek_item->type == Item::Type::Separator)
|
||||
if (item->action && peek_item->type == Item::Type::Separator)
|
||||
TRY(m_overflow_menu->try_add_separator());
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ private:
|
|||
RefPtr<Action> action;
|
||||
RefPtr<Widget> widget;
|
||||
};
|
||||
NonnullOwnPtrVector<Item> m_items;
|
||||
Vector<NonnullOwnPtr<Item>> m_items;
|
||||
RefPtr<Menu> m_overflow_menu;
|
||||
RefPtr<Action> m_overflow_action;
|
||||
RefPtr<Button> m_overflow_button;
|
||||
|
|
|
@ -28,7 +28,7 @@ void UndoStack::undo()
|
|||
return;
|
||||
|
||||
auto& command = m_stack[--m_stack_index];
|
||||
command.undo();
|
||||
command->undo();
|
||||
|
||||
if (on_state_change)
|
||||
on_state_change();
|
||||
|
@ -40,7 +40,7 @@ void UndoStack::redo()
|
|||
return;
|
||||
|
||||
auto& command = m_stack[m_stack_index++];
|
||||
command.redo();
|
||||
command->redo();
|
||||
|
||||
if (on_state_change)
|
||||
on_state_change();
|
||||
|
@ -56,7 +56,7 @@ ErrorOr<void> UndoStack::try_push(NonnullOwnPtr<Command> command)
|
|||
m_clean_index = {};
|
||||
|
||||
if (!m_stack.is_empty() && is_current_modified()) {
|
||||
if (m_stack.last().merge_with(*command))
|
||||
if (m_stack.last()->merge_with(*command))
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -114,14 +114,14 @@ Optional<DeprecatedString> UndoStack::undo_action_text() const
|
|||
{
|
||||
if (!can_undo())
|
||||
return {};
|
||||
return m_stack[m_stack_index - 1].action_text();
|
||||
return m_stack[m_stack_index - 1]->action_text();
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> UndoStack::redo_action_text() const
|
||||
{
|
||||
if (!can_redo())
|
||||
return {};
|
||||
return m_stack[m_stack_index].action_text();
|
||||
return m_stack[m_stack_index]->action_text();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
Function<void()> on_state_change;
|
||||
|
||||
private:
|
||||
NonnullOwnPtrVector<Command> m_stack;
|
||||
Vector<NonnullOwnPtr<Command>> m_stack;
|
||||
size_t m_stack_index { 0 };
|
||||
Optional<size_t> m_clean_index;
|
||||
Optional<Time> m_last_unmodified_timestamp;
|
||||
|
|
|
@ -21,7 +21,7 @@ DeprecatedString Document::render_to_html() const
|
|||
html_builder.append("</title>\n</head>\n"sv);
|
||||
html_builder.append("<body>\n"sv);
|
||||
for (auto& line : m_lines) {
|
||||
html_builder.append(line.render_to_html());
|
||||
html_builder.append(line->render_to_html());
|
||||
}
|
||||
html_builder.append("</body>"sv);
|
||||
html_builder.append("</html>"sv);
|
||||
|
|
|
@ -44,7 +44,7 @@ private:
|
|||
|
||||
void read_lines(StringView);
|
||||
|
||||
NonnullOwnPtrVector<Line> m_lines;
|
||||
Vector<NonnullOwnPtr<Line>> m_lines;
|
||||
URL m_url;
|
||||
bool m_inside_preformatted_block { false };
|
||||
bool m_inside_unordered_list { false };
|
||||
|
|
|
@ -77,7 +77,7 @@ struct GIFLoadingContext {
|
|||
size_t data_size { 0 };
|
||||
LogicalScreen logical_screen {};
|
||||
u8 background_color_index { 0 };
|
||||
NonnullOwnPtrVector<GIFImageDescriptor> images {};
|
||||
Vector<NonnullOwnPtr<GIFImageDescriptor>> images {};
|
||||
size_t loops { 1 };
|
||||
RefPtr<Gfx::Bitmap> frame_buffer;
|
||||
size_t current_frame { 0 };
|
||||
|
@ -284,11 +284,11 @@ static ErrorOr<void> decode_frame(GIFLoadingContext& context, size_t frame_index
|
|||
for (size_t i = start_frame; i <= frame_index; ++i) {
|
||||
auto& image = context.images.at(i);
|
||||
|
||||
auto const previous_image_disposal_method = i > 0 ? context.images.at(i - 1).disposal_method : GIFImageDescriptor::DisposalMethod::None;
|
||||
auto const previous_image_disposal_method = i > 0 ? context.images.at(i - 1)->disposal_method : GIFImageDescriptor::DisposalMethod::None;
|
||||
|
||||
if (i == 0) {
|
||||
context.frame_buffer->fill(Color::Transparent);
|
||||
} else if (i > 0 && image.disposal_method == GIFImageDescriptor::DisposalMethod::RestorePrevious
|
||||
} else if (i > 0 && image->disposal_method == GIFImageDescriptor::DisposalMethod::RestorePrevious
|
||||
&& previous_image_disposal_method != GIFImageDescriptor::DisposalMethod::RestorePrevious) {
|
||||
// This marks the start of a run of frames that once disposed should be restored to the
|
||||
// previous underlying image contents. Therefore we make a copy of the current frame
|
||||
|
@ -302,23 +302,23 @@ static ErrorOr<void> decode_frame(GIFLoadingContext& context, size_t frame_index
|
|||
// background color of the GIF itself. It appears that all major browsers and most other
|
||||
// GIF decoders adhere to the former interpretation, therefore we will do the same by
|
||||
// clearing the entire frame buffer to transparent.
|
||||
clear_rect(*context.frame_buffer, context.images.at(i - 1).rect(), Color::Transparent);
|
||||
clear_rect(*context.frame_buffer, context.images[i - 1]->rect(), Color::Transparent);
|
||||
} else if (i > 0 && previous_image_disposal_method == GIFImageDescriptor::DisposalMethod::RestorePrevious) {
|
||||
// Previous frame indicated that once disposed, it should be restored to *its* previous
|
||||
// underlying image contents, therefore we restore the saved previous frame buffer.
|
||||
copy_frame_buffer(*context.frame_buffer, *context.prev_frame_buffer);
|
||||
}
|
||||
|
||||
if (image.lzw_min_code_size > 8)
|
||||
if (image->lzw_min_code_size > 8)
|
||||
return Error::from_string_literal("LZW minimum code size is greater than 8");
|
||||
|
||||
LZWDecoder decoder(image.lzw_encoded_bytes, image.lzw_min_code_size);
|
||||
LZWDecoder decoder(image->lzw_encoded_bytes, image->lzw_min_code_size);
|
||||
|
||||
// Add GIF-specific control codes
|
||||
int const clear_code = decoder.add_control_code();
|
||||
int const end_of_information_code = decoder.add_control_code();
|
||||
|
||||
auto const& color_map = image.use_global_color_map ? context.logical_screen.color_map : image.color_map;
|
||||
auto const& color_map = image->use_global_color_map ? context.logical_screen.color_map : image->color_map;
|
||||
|
||||
int pixel_index = 0;
|
||||
int row = 0;
|
||||
|
@ -336,25 +336,25 @@ static ErrorOr<void> decode_frame(GIFLoadingContext& context, size_t frame_index
|
|||
}
|
||||
if (code.value() == end_of_information_code)
|
||||
break;
|
||||
if (!image.width)
|
||||
if (!image->width)
|
||||
continue;
|
||||
|
||||
auto colors = decoder.get_output();
|
||||
for (auto const& color : colors) {
|
||||
auto c = color_map[color];
|
||||
|
||||
int x = pixel_index % image.width + image.x;
|
||||
int y = row + image.y;
|
||||
int x = pixel_index % image->width + image->x;
|
||||
int y = row + image->y;
|
||||
|
||||
if (context.frame_buffer->rect().contains(x, y) && (!image.transparent || color != image.transparency_index)) {
|
||||
if (context.frame_buffer->rect().contains(x, y) && (!image->transparent || color != image->transparency_index)) {
|
||||
context.frame_buffer->set_pixel(x, y, c);
|
||||
}
|
||||
|
||||
++pixel_index;
|
||||
if (pixel_index % image.width == 0) {
|
||||
if (image.interlaced) {
|
||||
if (pixel_index % image->width == 0) {
|
||||
if (image->interlaced) {
|
||||
if (interlace_pass < 4) {
|
||||
if (row + INTERLACE_ROW_STRIDES[interlace_pass] >= image.height) {
|
||||
if (row + INTERLACE_ROW_STRIDES[interlace_pass] >= image->height) {
|
||||
++interlace_pass;
|
||||
if (interlace_pass < 4)
|
||||
row = INTERLACE_ROW_OFFSETS[interlace_pass];
|
||||
|
@ -471,28 +471,28 @@ static ErrorOr<void> load_gif_frame_descriptors(GIFLoadingContext& context)
|
|||
context.images.append(move(current_image));
|
||||
auto& image = context.images.last();
|
||||
|
||||
image.x = TRY(stream.read_value<LittleEndian<u16>>());
|
||||
image.y = TRY(stream.read_value<LittleEndian<u16>>());
|
||||
image.width = TRY(stream.read_value<LittleEndian<u16>>());
|
||||
image.height = TRY(stream.read_value<LittleEndian<u16>>());
|
||||
image->x = TRY(stream.read_value<LittleEndian<u16>>());
|
||||
image->y = TRY(stream.read_value<LittleEndian<u16>>());
|
||||
image->width = TRY(stream.read_value<LittleEndian<u16>>());
|
||||
image->height = TRY(stream.read_value<LittleEndian<u16>>());
|
||||
|
||||
auto packed_fields = TRY(stream.read_value<u8>());
|
||||
|
||||
image.use_global_color_map = !(packed_fields & 0x80);
|
||||
image.interlaced = (packed_fields & 0x40) != 0;
|
||||
image->use_global_color_map = !(packed_fields & 0x80);
|
||||
image->interlaced = (packed_fields & 0x40) != 0;
|
||||
|
||||
if (!image.use_global_color_map) {
|
||||
if (!image->use_global_color_map) {
|
||||
size_t local_color_table_size = AK::exp2<size_t>((packed_fields & 7) + 1);
|
||||
|
||||
for (size_t i = 0; i < local_color_table_size; ++i) {
|
||||
u8 r = TRY(stream.read_value<u8>());
|
||||
u8 g = TRY(stream.read_value<u8>());
|
||||
u8 b = TRY(stream.read_value<u8>());
|
||||
image.color_map[i] = { r, g, b };
|
||||
image->color_map[i] = { r, g, b };
|
||||
}
|
||||
}
|
||||
|
||||
image.lzw_min_code_size = TRY(stream.read_value<u8>());
|
||||
image->lzw_min_code_size = TRY(stream.read_value<u8>());
|
||||
|
||||
u8 lzw_encoded_bytes_expected = 0;
|
||||
|
||||
|
@ -505,7 +505,7 @@ static ErrorOr<void> load_gif_frame_descriptors(GIFLoadingContext& context)
|
|||
TRY(stream.read_entire_buffer(buffer.span().trim(lzw_encoded_bytes_expected)));
|
||||
|
||||
for (int i = 0; i < lzw_encoded_bytes_expected; ++i) {
|
||||
image.lzw_encoded_bytes.append(buffer[i]);
|
||||
image->lzw_encoded_bytes.append(buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -657,7 +657,7 @@ ErrorOr<ImageFrameDescriptor> GIFImageDecoderPlugin::frame(size_t index)
|
|||
|
||||
ImageFrameDescriptor frame {};
|
||||
frame.image = TRY(m_context->frame_buffer->clone());
|
||||
frame.duration = m_context->images.at(index).duration * 10;
|
||||
frame.duration = m_context->images[index]->duration * 10;
|
||||
|
||||
if (frame.duration <= 10) {
|
||||
frame.duration = 100;
|
||||
|
|
|
@ -122,7 +122,7 @@ void Job::flush_received_buffers()
|
|||
return;
|
||||
dbgln_if(JOB_DEBUG, "Job: Flushing received buffers: have {} bytes in {} buffers for {}", m_buffered_size, m_received_buffers.size(), m_request.url());
|
||||
for (size_t i = 0; i < m_received_buffers.size(); ++i) {
|
||||
auto& payload = m_received_buffers[i].pending_flush;
|
||||
auto& payload = m_received_buffers[i]->pending_flush;
|
||||
auto result = do_write(payload);
|
||||
if (result.is_error()) {
|
||||
if (!result.error().is_errno()) {
|
||||
|
@ -591,8 +591,8 @@ void Job::finish_up()
|
|||
|
||||
u8* flat_ptr = flattened_buffer.data();
|
||||
for (auto& received_buffer : m_received_buffers) {
|
||||
memcpy(flat_ptr, received_buffer.pending_flush.data(), received_buffer.pending_flush.size());
|
||||
flat_ptr += received_buffer.pending_flush.size();
|
||||
memcpy(flat_ptr, received_buffer->pending_flush.data(), received_buffer->pending_flush.size());
|
||||
flat_ptr += received_buffer->pending_flush.size();
|
||||
}
|
||||
m_received_buffers.clear();
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ protected:
|
|||
ReadonlyBytes pending_flush;
|
||||
};
|
||||
|
||||
NonnullOwnPtrVector<ReceivedBuffer> m_received_buffers;
|
||||
Vector<NonnullOwnPtr<ReceivedBuffer>> m_received_buffers;
|
||||
|
||||
size_t m_buffered_size { 0 };
|
||||
size_t m_received_size { 0 };
|
||||
|
|
|
@ -128,8 +128,8 @@ void ConnectionBase::handle_messages()
|
|||
{
|
||||
auto messages = move(m_unprocessed_messages);
|
||||
for (auto& message : messages) {
|
||||
if (message.endpoint_magic() == m_local_endpoint_magic) {
|
||||
auto handler_result = m_local_stub.handle(message);
|
||||
if (message->endpoint_magic() == m_local_endpoint_magic) {
|
||||
auto handler_result = m_local_stub.handle(*message);
|
||||
if (handler_result.is_error()) {
|
||||
dbgln("IPC::ConnectionBase::handle_messages: {}", handler_result.error());
|
||||
continue;
|
||||
|
@ -246,9 +246,9 @@ OwnPtr<IPC::Message> ConnectionBase::wait_for_specific_endpoint_message_impl(u32
|
|||
// Otherwise we might end up blocked for a while for no reason.
|
||||
for (size_t i = 0; i < m_unprocessed_messages.size(); ++i) {
|
||||
auto& message = m_unprocessed_messages[i];
|
||||
if (message.endpoint_magic() != endpoint_magic)
|
||||
if (message->endpoint_magic() != endpoint_magic)
|
||||
continue;
|
||||
if (message.message_id() == message_id)
|
||||
if (message->message_id() == message_id)
|
||||
return m_unprocessed_messages.take(i);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ protected:
|
|||
|
||||
RefPtr<Core::Timer> m_responsiveness_timer;
|
||||
|
||||
NonnullOwnPtrVector<Message> m_unprocessed_messages;
|
||||
Vector<NonnullOwnPtr<Message>> m_unprocessed_messages;
|
||||
ByteBuffer m_unprocessed_bytes;
|
||||
|
||||
u32 m_local_endpoint_magic { 0 };
|
||||
|
|
|
@ -12,7 +12,7 @@ void Executable::dump() const
|
|||
{
|
||||
dbgln("\033[33;1mJS::Bytecode::Executable\033[0m ({})", name);
|
||||
for (auto& block : basic_blocks)
|
||||
block.dump(*this);
|
||||
block->dump(*this);
|
||||
if (!string_table->is_empty()) {
|
||||
outln();
|
||||
string_table->dump();
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace JS::Bytecode {
|
|||
|
||||
struct Executable {
|
||||
DeprecatedFlyString name;
|
||||
NonnullOwnPtrVector<BasicBlock> basic_blocks;
|
||||
Vector<NonnullOwnPtr<BasicBlock>> basic_blocks;
|
||||
NonnullOwnPtr<StringTable> string_table;
|
||||
NonnullOwnPtr<IdentifierTable> identifier_table;
|
||||
size_t number_of_registers { 0 };
|
||||
|
|
|
@ -36,9 +36,9 @@ CodeGenerationErrorOr<NonnullOwnPtr<Executable>> Generator::generate(ASTNode con
|
|||
if (generator.is_in_generator_or_async_function()) {
|
||||
// Terminate all unterminated blocks with yield return
|
||||
for (auto& block : generator.m_root_basic_blocks) {
|
||||
if (block.is_terminated())
|
||||
if (block->is_terminated())
|
||||
continue;
|
||||
generator.switch_to_basic_block(block);
|
||||
generator.switch_to_basic_block(*block);
|
||||
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
|
||||
generator.emit<Bytecode::Op::Yield>(nullptr);
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
if (name.is_empty())
|
||||
name = DeprecatedString::number(m_next_block++);
|
||||
m_root_basic_blocks.append(BasicBlock::create(name));
|
||||
return m_root_basic_blocks.last();
|
||||
return *m_root_basic_blocks.last();
|
||||
}
|
||||
|
||||
bool is_current_block_terminated() const
|
||||
|
@ -227,7 +227,7 @@ private:
|
|||
};
|
||||
|
||||
BasicBlock* m_current_basic_block { nullptr };
|
||||
NonnullOwnPtrVector<BasicBlock> m_root_basic_blocks;
|
||||
Vector<NonnullOwnPtr<BasicBlock>> m_root_basic_blocks;
|
||||
NonnullOwnPtr<StringTable> m_string_table;
|
||||
NonnullOwnPtr<IdentifierTable> m_identifier_table;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable const& e
|
|||
pushed_execution_context = true;
|
||||
}
|
||||
|
||||
TemporaryChange restore_current_block { m_current_block, entry_point ?: &executable.basic_blocks.first() };
|
||||
TemporaryChange restore_current_block { m_current_block, entry_point ?: executable.basic_blocks.first() };
|
||||
|
||||
if (in_frame)
|
||||
m_register_windows.append(in_frame);
|
||||
|
|
|
@ -164,7 +164,7 @@ void GenerateCFG::perform(PassPipelineExecutable& executable)
|
|||
|
||||
unwind_frames.append(&top_level_frame);
|
||||
|
||||
generate_cfg_for_block(executable.executable.basic_blocks.first(), executable);
|
||||
generate_cfg_for_block(*executable.executable.basic_blocks.first(), executable);
|
||||
|
||||
finished();
|
||||
}
|
||||
|
|
|
@ -175,20 +175,20 @@ void EliminateLoads::perform(PassPipelineExecutable& executable)
|
|||
// save some work between blocks
|
||||
for (auto it = executable.executable.basic_blocks.begin(); it != executable.executable.basic_blocks.end(); ++it) {
|
||||
auto const& old_block = *it;
|
||||
auto new_block = eliminate_loads(old_block, executable.executable.number_of_registers);
|
||||
auto new_block = eliminate_loads(*old_block, executable.executable.number_of_registers);
|
||||
|
||||
// We will replace the old block, with a new one, so we need to replace all references,
|
||||
// to the old one with the new one
|
||||
for (auto& block : executable.executable.basic_blocks) {
|
||||
InstructionStreamIterator it { block.instruction_stream() };
|
||||
InstructionStreamIterator it { block->instruction_stream() };
|
||||
while (!it.at_end()) {
|
||||
auto& instruction = *it;
|
||||
++it;
|
||||
const_cast<Instruction&>(instruction).replace_references(old_block, *new_block);
|
||||
const_cast<Instruction&>(instruction).replace_references(*old_block, *new_block);
|
||||
}
|
||||
}
|
||||
|
||||
executable.executable.basic_blocks.ptr_at(it.index()) = move(new_block);
|
||||
executable.executable.basic_blocks[it.index()] = move(new_block);
|
||||
}
|
||||
|
||||
finished();
|
||||
|
|
|
@ -81,7 +81,7 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
|
|||
first_successor_position = it.index();
|
||||
}
|
||||
for (auto& block : executable.executable.basic_blocks) {
|
||||
InstructionStreamIterator it { block.instruction_stream() };
|
||||
InstructionStreamIterator it { block->instruction_stream() };
|
||||
while (!it.at_end()) {
|
||||
auto& instruction = *it;
|
||||
++it;
|
||||
|
|
|
@ -35,7 +35,7 @@ void PlaceBlocks::perform(PassPipelineExecutable& executable)
|
|||
};
|
||||
|
||||
// Make sure to visit the entry block first
|
||||
visit(&executable.executable.basic_blocks.first());
|
||||
visit(executable.executable.basic_blocks.first());
|
||||
|
||||
for (auto& entry : cfg)
|
||||
visit(entry.key);
|
||||
|
|
|
@ -22,19 +22,19 @@ void UnifySameBlocks::perform(PassPipelineExecutable& executable)
|
|||
|
||||
for (size_t i = 0; i < executable.executable.basic_blocks.size(); ++i) {
|
||||
auto& block = executable.executable.basic_blocks[i];
|
||||
auto block_bytes = block.instruction_stream();
|
||||
auto block_bytes = block->instruction_stream();
|
||||
for (auto& candidate_block : executable.executable.basic_blocks.span().slice(i + 1)) {
|
||||
if (equal_blocks.contains(&*candidate_block))
|
||||
continue;
|
||||
// FIXME: This can probably be relaxed a bit...
|
||||
if (candidate_block->size() != block.size())
|
||||
if (candidate_block->size() != block->size())
|
||||
continue;
|
||||
|
||||
auto candidate_bytes = candidate_block->instruction_stream();
|
||||
// FIXME: NewBigInt's value is not correctly reflected by its encoding in memory,
|
||||
// this will yield false negatives for blocks containing that
|
||||
if (memcmp(candidate_bytes.data(), block_bytes.data(), candidate_block->size()) == 0)
|
||||
equal_blocks.set(&*candidate_block, &block);
|
||||
equal_blocks.set(candidate_block.ptr(), block);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ void UnifySameBlocks::perform(PassPipelineExecutable& executable)
|
|||
first_successor_position = it.index();
|
||||
|
||||
for (auto& block : executable.executable.basic_blocks) {
|
||||
InstructionStreamIterator it { block.instruction_stream() };
|
||||
InstructionStreamIterator it { block->instruction_stream() };
|
||||
while (!it.at_end()) {
|
||||
auto& instruction = *it;
|
||||
++it;
|
||||
|
|
|
@ -61,12 +61,12 @@ public:
|
|||
{
|
||||
started();
|
||||
for (auto& pass : m_passes)
|
||||
pass.perform(executable);
|
||||
pass->perform(executable);
|
||||
finished();
|
||||
}
|
||||
|
||||
private:
|
||||
NonnullOwnPtrVector<Pass> m_passes;
|
||||
Vector<NonnullOwnPtr<Pass>> m_passes;
|
||||
};
|
||||
|
||||
namespace Passes {
|
||||
|
|
|
@ -22,15 +22,15 @@ DeprecatedString ContainerBlock::render_to_html(bool tight) const
|
|||
StringBuilder builder;
|
||||
|
||||
for (size_t i = 0; i + 1 < m_blocks.size(); ++i) {
|
||||
auto s = m_blocks[i].render_to_html(tight);
|
||||
auto s = m_blocks[i]->render_to_html(tight);
|
||||
builder.append(s);
|
||||
}
|
||||
|
||||
// I don't like this edge case.
|
||||
if (m_blocks.size() != 0) {
|
||||
auto& block = m_blocks[m_blocks.size() - 1];
|
||||
auto s = block.render_to_html(tight);
|
||||
if (tight && dynamic_cast<Paragraph const*>(&block)) {
|
||||
auto s = block->render_to_html(tight);
|
||||
if (tight && dynamic_cast<Paragraph const*>(block.ptr())) {
|
||||
builder.append(s.substring_view(0, s.length() - 1));
|
||||
} else {
|
||||
builder.append(s);
|
||||
|
@ -45,7 +45,7 @@ Vector<DeprecatedString> ContainerBlock::render_lines_for_terminal(size_t view_w
|
|||
Vector<DeprecatedString> lines;
|
||||
|
||||
for (auto& block : m_blocks) {
|
||||
for (auto& line : block.render_lines_for_terminal(view_width))
|
||||
for (auto& line : block->render_lines_for_terminal(view_width))
|
||||
lines.append(move(line));
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ RecursionDecision ContainerBlock::walk(Visitor& visitor) const
|
|||
return rd;
|
||||
|
||||
for (auto const& block : m_blocks) {
|
||||
rd = block.walk(visitor);
|
||||
rd = block->walk(visitor);
|
||||
if (rd == RecursionDecision::Break)
|
||||
return rd;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ RecursionDecision ContainerBlock::walk(Visitor& visitor) const
|
|||
}
|
||||
|
||||
template<class CodeBlock>
|
||||
static bool try_parse_block(LineIterator& lines, NonnullOwnPtrVector<Block>& blocks, Heading* current_section)
|
||||
static bool try_parse_block(LineIterator& lines, Vector<NonnullOwnPtr<Block>>& blocks, Heading* current_section)
|
||||
{
|
||||
OwnPtr<CodeBlock> block = CodeBlock::parse(lines, current_section);
|
||||
if (!block)
|
||||
|
@ -78,7 +78,7 @@ static bool try_parse_block(LineIterator& lines, NonnullOwnPtrVector<Block>& blo
|
|||
}
|
||||
|
||||
template<typename BlockType>
|
||||
static bool try_parse_block(LineIterator& lines, NonnullOwnPtrVector<Block>& blocks)
|
||||
static bool try_parse_block(LineIterator& lines, Vector<NonnullOwnPtr<Block>>& blocks)
|
||||
{
|
||||
OwnPtr<BlockType> block = BlockType::parse(lines);
|
||||
if (!block)
|
||||
|
@ -89,7 +89,7 @@ static bool try_parse_block(LineIterator& lines, NonnullOwnPtrVector<Block>& blo
|
|||
|
||||
OwnPtr<ContainerBlock> ContainerBlock::parse(LineIterator& lines)
|
||||
{
|
||||
NonnullOwnPtrVector<Block> blocks;
|
||||
Vector<NonnullOwnPtr<Block>> blocks;
|
||||
|
||||
StringBuilder paragraph_text;
|
||||
Heading* current_section = nullptr;
|
||||
|
@ -121,7 +121,7 @@ OwnPtr<ContainerBlock> ContainerBlock::parse(LineIterator& lines)
|
|||
|
||||
bool heading = false;
|
||||
if ((heading = try_parse_block<Heading>(lines, blocks)))
|
||||
current_section = dynamic_cast<Heading*>(&blocks.last());
|
||||
current_section = dynamic_cast<Heading*>(blocks.last().ptr());
|
||||
|
||||
bool any = heading
|
||||
|| try_parse_block<Table>(lines, blocks)
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Markdown {
|
|||
|
||||
class ContainerBlock final : public Block {
|
||||
public:
|
||||
ContainerBlock(NonnullOwnPtrVector<Block> blocks, bool has_blank_lines, bool has_trailing_blank_lines)
|
||||
ContainerBlock(Vector<NonnullOwnPtr<Block>> blocks, bool has_blank_lines, bool has_trailing_blank_lines)
|
||||
: m_blocks(move(blocks))
|
||||
, m_has_blank_lines(has_blank_lines)
|
||||
, m_has_trailing_blank_lines(has_trailing_blank_lines)
|
||||
|
@ -35,10 +35,10 @@ public:
|
|||
bool has_blank_lines() const { return m_has_blank_lines; }
|
||||
bool has_trailing_blank_lines() const { return m_has_trailing_blank_lines; }
|
||||
|
||||
NonnullOwnPtrVector<Block> const& blocks() const { return m_blocks; }
|
||||
Vector<NonnullOwnPtr<Block>> const& blocks() const { return m_blocks; }
|
||||
|
||||
private:
|
||||
NonnullOwnPtrVector<Block> m_blocks;
|
||||
Vector<NonnullOwnPtr<Block>> m_blocks;
|
||||
bool m_has_blank_lines;
|
||||
bool m_has_trailing_blank_lines;
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ DeprecatedString List::render_to_html(bool) const
|
|||
|
||||
for (auto& item : m_items) {
|
||||
builder.append("<li>"sv);
|
||||
if (!m_is_tight || (item->blocks().size() != 0 && !dynamic_cast<Paragraph const*>(&(item->blocks()[0]))))
|
||||
if (!m_is_tight || (item->blocks().size() != 0 && !dynamic_cast<Paragraph const*>(item->blocks()[0].ptr())))
|
||||
builder.append('\n');
|
||||
builder.append(item->render_to_html(m_is_tight));
|
||||
builder.append("</li>\n"sv);
|
||||
|
|
|
@ -194,14 +194,14 @@ RecursionDecision Text::LinkNode::walk(Visitor& visitor) const
|
|||
void Text::MultiNode::render_to_html(StringBuilder& builder) const
|
||||
{
|
||||
for (auto& child : children) {
|
||||
child.render_to_html(builder);
|
||||
child->render_to_html(builder);
|
||||
}
|
||||
}
|
||||
|
||||
void Text::MultiNode::render_for_terminal(StringBuilder& builder) const
|
||||
{
|
||||
for (auto& child : children) {
|
||||
child.render_for_terminal(builder);
|
||||
child->render_for_terminal(builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ size_t Text::MultiNode::terminal_length() const
|
|||
{
|
||||
size_t length = 0;
|
||||
for (auto& child : children) {
|
||||
length += child.terminal_length();
|
||||
length += child->terminal_length();
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ RecursionDecision Text::MultiNode::walk(Visitor& visitor) const
|
|||
return rd;
|
||||
|
||||
for (auto const& child : children) {
|
||||
rd = child.walk(visitor);
|
||||
rd = child->walk(visitor);
|
||||
if (rd == RecursionDecision::Break)
|
||||
return rd;
|
||||
}
|
||||
|
@ -550,8 +550,8 @@ NonnullOwnPtr<Text::Node> Text::parse_code(Vector<Token>::ConstIterator& tokens)
|
|||
|
||||
// Strip first and last space, when appropriate.
|
||||
if (!is_all_whitespace) {
|
||||
auto& first = dynamic_cast<TextNode&>(code->children.first());
|
||||
auto& last = dynamic_cast<TextNode&>(code->children.last());
|
||||
auto& first = dynamic_cast<TextNode&>(*code->children.first());
|
||||
auto& last = dynamic_cast<TextNode&>(*code->children.last());
|
||||
if (first.text.starts_with(' ') && last.text.ends_with(' ')) {
|
||||
first.text = first.text.substring(1);
|
||||
last.text = last.text.substring(0, last.text.length() - 1);
|
||||
|
@ -653,8 +653,8 @@ NonnullOwnPtr<Text::Node> Text::parse_strike_through(Vector<Token>::ConstIterato
|
|||
tokens = iterator;
|
||||
|
||||
if (!is_all_whitespace) {
|
||||
auto& first = dynamic_cast<TextNode&>(striked_text->children.first());
|
||||
auto& last = dynamic_cast<TextNode&>(striked_text->children.last());
|
||||
auto& first = dynamic_cast<TextNode&>(*striked_text->children.first());
|
||||
auto& last = dynamic_cast<TextNode&>(*striked_text->children.last());
|
||||
if (first.text.starts_with(' ') && last.text.ends_with(' ')) {
|
||||
first.text = first.text.substring(1);
|
||||
last.text = last.text.substring(0, last.text.length() - 1);
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
|
||||
class MultiNode : public Node {
|
||||
public:
|
||||
NonnullOwnPtrVector<Node> children;
|
||||
Vector<NonnullOwnPtr<Node>> children;
|
||||
|
||||
virtual void render_to_html(StringBuilder& builder) const override;
|
||||
virtual void render_for_terminal(StringBuilder& builder) const override;
|
||||
|
|
|
@ -33,7 +33,7 @@ void Terminal::clear()
|
|||
{
|
||||
dbgln_if(TERMINAL_DEBUG, "Clear the entire screen");
|
||||
for (size_t i = 0; i < rows(); ++i)
|
||||
active_buffer()[i].clear();
|
||||
active_buffer()[i]->clear();
|
||||
set_cursor(0, 0);
|
||||
}
|
||||
|
||||
|
@ -715,7 +715,7 @@ void Terminal::linefeed()
|
|||
u16 new_row = cursor_row();
|
||||
#ifndef KERNEL
|
||||
if (!m_controls_are_logically_generated)
|
||||
active_buffer()[new_row].set_terminated(m_column_before_carriage_return.value_or(cursor_column()));
|
||||
active_buffer()[new_row]->set_terminated(m_column_before_carriage_return.value_or(cursor_column()));
|
||||
#endif
|
||||
if (cursor_row() == m_scroll_region_bottom) {
|
||||
scroll_up();
|
||||
|
@ -763,26 +763,26 @@ void Terminal::scroll_up(u16 region_top, u16 region_bottom, size_t count)
|
|||
auto remaining_lines = max_history_size() - history_size();
|
||||
history_delta = (count > remaining_lines) ? remaining_lines - count : 0;
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
add_line_to_history(move(active_buffer().ptr_at(region_top + i)));
|
||||
add_line_to_history(move(active_buffer().at(region_top + i)));
|
||||
}
|
||||
|
||||
// Move lines into their new place.
|
||||
for (u16 row = region_top; row + count <= region_bottom; ++row)
|
||||
swap(active_buffer().ptr_at(row), active_buffer().ptr_at(row + count));
|
||||
swap(active_buffer().at(row), active_buffer().at(row + count));
|
||||
// Clear 'new' lines at the bottom.
|
||||
if (should_move_to_scrollback) {
|
||||
// Since we moved the previous lines into history, we can't just clear them.
|
||||
for (u16 row = region_bottom + 1 - count; row <= region_bottom; ++row)
|
||||
active_buffer().ptr_at(row) = make<Line>(columns());
|
||||
active_buffer().at(row) = make<Line>(columns());
|
||||
} else {
|
||||
// The new lines haven't been moved and we don't want to leak memory.
|
||||
for (u16 row = region_bottom + 1 - count; row <= region_bottom; ++row)
|
||||
active_buffer()[row].clear();
|
||||
active_buffer()[row]->clear();
|
||||
}
|
||||
// Set dirty flag on swapped lines.
|
||||
// The other lines have implicitly been set dirty by being cleared.
|
||||
for (u16 row = region_top; row + count <= region_bottom; ++row)
|
||||
active_buffer()[row].set_dirty(true);
|
||||
active_buffer()[row]->set_dirty(true);
|
||||
m_client.terminal_history_changed(history_delta);
|
||||
}
|
||||
|
||||
|
@ -800,14 +800,14 @@ void Terminal::scroll_down(u16 region_top, u16 region_bottom, size_t count)
|
|||
|
||||
// Move lines into their new place.
|
||||
for (int row = region_bottom; row >= static_cast<int>(region_top + count); --row)
|
||||
swap(active_buffer().ptr_at(row), active_buffer().ptr_at(row - count));
|
||||
swap(active_buffer().at(row), active_buffer().at(row - count));
|
||||
// Clear the 'new' lines at the top.
|
||||
for (u16 row = region_top; row < region_top + count; ++row)
|
||||
active_buffer()[row].clear();
|
||||
active_buffer()[row]->clear();
|
||||
// Set dirty flag on swapped lines.
|
||||
// The other lines have implicitly been set dirty by being cleared.
|
||||
for (u16 row = region_top + count; row <= region_bottom; ++row)
|
||||
active_buffer()[row].set_dirty(true);
|
||||
active_buffer()[row]->set_dirty(true);
|
||||
}
|
||||
|
||||
// Insert `count` blank cells at the end of the line. Text moves left.
|
||||
|
@ -820,9 +820,9 @@ void Terminal::scroll_left(u16 row, u16 column, size_t count)
|
|||
|
||||
auto& line = active_buffer()[row];
|
||||
for (size_t i = column; i < columns() - count; ++i)
|
||||
swap(line.cell_at(i), line.cell_at(i + count));
|
||||
swap(line->cell_at(i), line->cell_at(i + count));
|
||||
clear_in_line(row, columns() - count, columns() - 1);
|
||||
line.set_dirty(true);
|
||||
line->set_dirty(true);
|
||||
}
|
||||
|
||||
// Insert `count` blank cells after `row`. Text moves right.
|
||||
|
@ -835,9 +835,9 @@ void Terminal::scroll_right(u16 row, u16 column, size_t count)
|
|||
|
||||
auto& line = active_buffer()[row];
|
||||
for (int i = columns() - 1; i >= static_cast<int>(column + count); --i)
|
||||
swap(line.cell_at(i), line.cell_at(i - count));
|
||||
swap(line->cell_at(i), line->cell_at(i - count));
|
||||
clear_in_line(row, column, column + count - 1);
|
||||
line.set_dirty(true);
|
||||
line->set_dirty(true);
|
||||
}
|
||||
|
||||
void Terminal::put_character_at(unsigned row, unsigned column, u32 code_point)
|
||||
|
@ -845,10 +845,10 @@ void Terminal::put_character_at(unsigned row, unsigned column, u32 code_point)
|
|||
VERIFY(row < rows());
|
||||
VERIFY(column < columns());
|
||||
auto& line = active_buffer()[row];
|
||||
line.set_code_point(column, code_point);
|
||||
line.attribute_at(column) = m_current_state.attribute;
|
||||
line.attribute_at(column).flags |= Attribute::Flags::Touched;
|
||||
line.set_dirty(true);
|
||||
line->set_code_point(column, code_point);
|
||||
line->attribute_at(column) = m_current_state.attribute;
|
||||
line->attribute_at(column).flags |= Attribute::Flags::Touched;
|
||||
line->set_dirty(true);
|
||||
|
||||
m_last_code_point = code_point;
|
||||
}
|
||||
|
@ -856,7 +856,7 @@ void Terminal::put_character_at(unsigned row, unsigned column, u32 code_point)
|
|||
void Terminal::clear_in_line(u16 row, u16 first_column, u16 last_column)
|
||||
{
|
||||
VERIFY(row < rows());
|
||||
active_buffer()[row].clear_range(first_column, last_column, m_current_state.attribute);
|
||||
active_buffer()[row]->clear_range(first_column, last_column, m_current_state.attribute);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1504,44 +1504,44 @@ void Terminal::set_size(u16 columns, u16 rows)
|
|||
if (forwards) {
|
||||
for (size_t i = 1; i <= buffer.size(); ++i) {
|
||||
auto is_at_seam = i == 1;
|
||||
auto next_line = is_at_seam ? nullptr : &buffer[buffer.size() - i + 1];
|
||||
auto& line = buffer[buffer.size() - i];
|
||||
Line* next_line = is_at_seam ? nullptr : buffer[buffer.size() - i + 1].ptr();
|
||||
Line* line = buffer[buffer.size() - i].ptr();
|
||||
auto next_cursor = cursor_on_line(buffer.size() - i + 1);
|
||||
line.rewrap(columns, next_line, next_cursor ?: cursor_on_line(buffer.size() - i), !!next_cursor);
|
||||
line->rewrap(columns, next_line, next_cursor ?: cursor_on_line(buffer.size() - i), !!next_cursor);
|
||||
}
|
||||
} else {
|
||||
for (size_t i = 0; i < buffer.size(); ++i) {
|
||||
auto is_at_seam = i + 1 == buffer.size();
|
||||
auto next_line = is_at_seam ? nullptr : &buffer[i + 1];
|
||||
Line* next_line = is_at_seam ? nullptr : buffer[i + 1].ptr();
|
||||
auto next_cursor = cursor_on_line(i + 1);
|
||||
buffer[i].rewrap(columns, next_line, next_cursor ?: cursor_on_line(i), !!next_cursor);
|
||||
buffer[i]->rewrap(columns, next_line, next_cursor ?: cursor_on_line(i), !!next_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
Queue<size_t> lines_to_reevaluate;
|
||||
for (size_t i = 0; i < buffer.size(); ++i) {
|
||||
if (buffer[i].length() != columns)
|
||||
if (buffer[i]->length() != columns)
|
||||
lines_to_reevaluate.enqueue(i);
|
||||
}
|
||||
while (!lines_to_reevaluate.is_empty()) {
|
||||
auto index = lines_to_reevaluate.dequeue();
|
||||
auto is_at_seam = index + 1 == buffer.size();
|
||||
auto next_line = is_at_seam ? nullptr : &buffer[index + 1];
|
||||
auto& line = buffer[index];
|
||||
Line* const next_line = is_at_seam ? nullptr : buffer[index + 1].ptr();
|
||||
Line* const line = buffer[index].ptr();
|
||||
auto next_cursor = cursor_on_line(index + 1);
|
||||
line.rewrap(columns, next_line, next_cursor ?: cursor_on_line(index), !!next_cursor);
|
||||
if (line.length() > columns) {
|
||||
line->rewrap(columns, next_line, next_cursor ?: cursor_on_line(index), !!next_cursor);
|
||||
if (line->length() > columns) {
|
||||
auto current_cursor = cursor_on_line(index);
|
||||
// Split the line into two (or more)
|
||||
++index;
|
||||
buffer.insert(index, make<Line>(0));
|
||||
VERIFY(buffer[index].length() == 0);
|
||||
line.rewrap(columns, &buffer[index], current_cursor, false);
|
||||
VERIFY(buffer[index]->length() == 0);
|
||||
line->rewrap(columns, buffer[index].ptr(), current_cursor, false);
|
||||
// If we inserted a line and the old cursor was after that line, increment its row
|
||||
if (!current_cursor && old_cursor.row >= index)
|
||||
++old_cursor.row;
|
||||
|
||||
if (buffer[index].length() != columns)
|
||||
if (buffer[index]->length() != columns)
|
||||
lines_to_reevaluate.enqueue(index);
|
||||
}
|
||||
if (next_line && next_line->length() != columns)
|
||||
|
@ -1550,7 +1550,7 @@ void Terminal::set_size(u16 columns, u16 rows)
|
|||
}
|
||||
|
||||
for (auto& line : buffer)
|
||||
line.set_length(columns);
|
||||
line->set_length(columns);
|
||||
|
||||
return old_cursor;
|
||||
};
|
||||
|
@ -1563,8 +1563,8 @@ void Terminal::set_size(u16 columns, u16 rows)
|
|||
while (extra_lines > 0) {
|
||||
if (m_history.size() <= cursor_tracker.row)
|
||||
break;
|
||||
if (m_history.last().is_empty()) {
|
||||
if (m_history.size() >= 2 && m_history[m_history.size() - 2].termination_column().has_value())
|
||||
if (m_history.last()->is_empty()) {
|
||||
if (m_history.size() >= 2 && m_history[m_history.size() - 2]->termination_column().has_value())
|
||||
break;
|
||||
--extra_lines;
|
||||
(void)m_history.take_last();
|
||||
|
@ -1635,7 +1635,7 @@ void Terminal::set_size(u16 columns, u16 rows)
|
|||
void Terminal::invalidate_cursor()
|
||||
{
|
||||
if (cursor_row() < active_buffer().size())
|
||||
active_buffer()[cursor_row()].set_dirty(true);
|
||||
active_buffer()[cursor_row()]->set_dirty(true);
|
||||
}
|
||||
|
||||
Attribute Terminal::attribute_at(Position const& position) const
|
||||
|
|
|
@ -120,11 +120,11 @@ public:
|
|||
Line& line(size_t index)
|
||||
{
|
||||
if (m_use_alternate_screen_buffer) {
|
||||
return m_alternate_screen_buffer[index];
|
||||
return *m_alternate_screen_buffer[index];
|
||||
} else {
|
||||
if (index < m_history.size())
|
||||
return m_history[(m_history_start + index) % m_history.size()];
|
||||
return m_normal_screen_buffer[index - m_history.size()];
|
||||
return *m_history[(m_history_start + index) % m_history.size()];
|
||||
return *m_normal_screen_buffer[index - m_history.size()];
|
||||
}
|
||||
}
|
||||
Line const& line(size_t index) const
|
||||
|
@ -134,12 +134,12 @@ public:
|
|||
|
||||
Line& visible_line(size_t index)
|
||||
{
|
||||
return active_buffer()[index];
|
||||
return *active_buffer()[index];
|
||||
}
|
||||
|
||||
Line const& visible_line(size_t index) const
|
||||
{
|
||||
return active_buffer()[index];
|
||||
return *active_buffer()[index];
|
||||
}
|
||||
|
||||
size_t max_history_size() const { return m_max_history_lines; }
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
}
|
||||
|
||||
if (m_max_history_lines > value) {
|
||||
NonnullOwnPtrVector<Line> new_history;
|
||||
Vector<NonnullOwnPtr<Line>> new_history;
|
||||
new_history.ensure_capacity(value);
|
||||
auto existing_line_count = min(m_history.size(), value);
|
||||
for (size_t i = m_history.size() - existing_line_count; i < m_history.size(); ++i) {
|
||||
|
@ -381,7 +381,7 @@ protected:
|
|||
EscapeSequenceParser m_parser;
|
||||
#ifndef KERNEL
|
||||
size_t m_history_start = 0;
|
||||
NonnullOwnPtrVector<Line> m_history;
|
||||
Vector<NonnullOwnPtr<Line>> m_history;
|
||||
void add_line_to_history(NonnullOwnPtr<Line>&& line)
|
||||
{
|
||||
if (max_history_size() == 0)
|
||||
|
@ -397,14 +397,14 @@ protected:
|
|||
|
||||
return;
|
||||
}
|
||||
m_history.ptr_at(m_history_start) = move(line);
|
||||
m_history[m_history_start] = move(line);
|
||||
m_history_start = (m_history_start + 1) % m_history.size();
|
||||
}
|
||||
|
||||
NonnullOwnPtrVector<Line>& active_buffer() { return m_use_alternate_screen_buffer ? m_alternate_screen_buffer : m_normal_screen_buffer; };
|
||||
NonnullOwnPtrVector<Line> const& active_buffer() const { return m_use_alternate_screen_buffer ? m_alternate_screen_buffer : m_normal_screen_buffer; };
|
||||
NonnullOwnPtrVector<Line> m_normal_screen_buffer;
|
||||
NonnullOwnPtrVector<Line> m_alternate_screen_buffer;
|
||||
Vector<NonnullOwnPtr<Line>>& active_buffer() { return m_use_alternate_screen_buffer ? m_alternate_screen_buffer : m_normal_screen_buffer; };
|
||||
Vector<NonnullOwnPtr<Line>> const& active_buffer() const { return m_use_alternate_screen_buffer ? m_alternate_screen_buffer : m_normal_screen_buffer; };
|
||||
Vector<NonnullOwnPtr<Line>> m_normal_screen_buffer;
|
||||
Vector<NonnullOwnPtr<Line>> m_alternate_screen_buffer;
|
||||
#endif
|
||||
|
||||
bool m_use_alternate_screen_buffer { false };
|
||||
|
|
|
@ -257,7 +257,7 @@ NonnullOwnPtr<MediaCondition> MediaCondition::from_not(NonnullOwnPtr<MediaCondit
|
|||
return adopt_own(*result);
|
||||
}
|
||||
|
||||
NonnullOwnPtr<MediaCondition> MediaCondition::from_and_list(NonnullOwnPtrVector<MediaCondition>&& conditions)
|
||||
NonnullOwnPtr<MediaCondition> MediaCondition::from_and_list(Vector<NonnullOwnPtr<MediaCondition>>&& conditions)
|
||||
{
|
||||
auto result = new MediaCondition;
|
||||
result->type = Type::And;
|
||||
|
@ -266,7 +266,7 @@ NonnullOwnPtr<MediaCondition> MediaCondition::from_and_list(NonnullOwnPtrVector<
|
|||
return adopt_own(*result);
|
||||
}
|
||||
|
||||
NonnullOwnPtr<MediaCondition> MediaCondition::from_or_list(NonnullOwnPtrVector<MediaCondition>&& conditions)
|
||||
NonnullOwnPtr<MediaCondition> MediaCondition::from_or_list(Vector<NonnullOwnPtr<MediaCondition>>&& conditions)
|
||||
{
|
||||
auto result = new MediaCondition;
|
||||
result->type = Type::Or;
|
||||
|
@ -285,7 +285,7 @@ ErrorOr<String> MediaCondition::to_string() const
|
|||
break;
|
||||
case Type::Not:
|
||||
builder.append("not "sv);
|
||||
builder.append(TRY(conditions.first().to_string()));
|
||||
builder.append(TRY(conditions.first()->to_string()));
|
||||
break;
|
||||
case Type::And:
|
||||
builder.join(" and "sv, conditions);
|
||||
|
@ -307,11 +307,11 @@ MatchResult MediaCondition::evaluate(HTML::Window const& window) const
|
|||
case Type::Single:
|
||||
return as_match_result(feature->evaluate(window));
|
||||
case Type::Not:
|
||||
return negate(conditions.first().evaluate(window));
|
||||
return negate(conditions.first()->evaluate(window));
|
||||
case Type::And:
|
||||
return evaluate_and(conditions, [&](auto& child) { return child.evaluate(window); });
|
||||
return evaluate_and(conditions, [&](auto& child) { return child->evaluate(window); });
|
||||
case Type::Or:
|
||||
return evaluate_or(conditions, [&](auto& child) { return child.evaluate(window); });
|
||||
return evaluate_or(conditions, [&](auto& child) { return child->evaluate(window); });
|
||||
case Type::GeneralEnclosed:
|
||||
return general_enclosed->evaluate();
|
||||
}
|
||||
|
|
|
@ -197,8 +197,8 @@ struct MediaCondition {
|
|||
static NonnullOwnPtr<MediaCondition> from_general_enclosed(GeneralEnclosed&&);
|
||||
static NonnullOwnPtr<MediaCondition> from_feature(MediaFeature&&);
|
||||
static NonnullOwnPtr<MediaCondition> from_not(NonnullOwnPtr<MediaCondition>&&);
|
||||
static NonnullOwnPtr<MediaCondition> from_and_list(NonnullOwnPtrVector<MediaCondition>&&);
|
||||
static NonnullOwnPtr<MediaCondition> from_or_list(NonnullOwnPtrVector<MediaCondition>&&);
|
||||
static NonnullOwnPtr<MediaCondition> from_and_list(Vector<NonnullOwnPtr<MediaCondition>>&&);
|
||||
static NonnullOwnPtr<MediaCondition> from_or_list(Vector<NonnullOwnPtr<MediaCondition>>&&);
|
||||
|
||||
MatchResult evaluate(HTML::Window const&) const;
|
||||
ErrorOr<String> to_string() const;
|
||||
|
@ -207,7 +207,7 @@ private:
|
|||
MediaCondition() = default;
|
||||
Type type;
|
||||
Optional<MediaFeature> feature;
|
||||
NonnullOwnPtrVector<MediaCondition> conditions;
|
||||
Vector<NonnullOwnPtr<MediaCondition>> conditions;
|
||||
Optional<GeneralEnclosed> general_enclosed;
|
||||
};
|
||||
|
||||
|
|
|
@ -834,7 +834,7 @@ OwnPtr<MediaCondition> Parser::parse_media_condition(TokenStream<ComponentValue>
|
|||
return maybe_media_in_parens.release_nonnull();
|
||||
}
|
||||
|
||||
NonnullOwnPtrVector<MediaCondition> child_conditions;
|
||||
Vector<NonnullOwnPtr<MediaCondition>> child_conditions;
|
||||
child_conditions.append(maybe_media_in_parens.release_nonnull());
|
||||
|
||||
// `<media-and>*`
|
||||
|
@ -7091,7 +7091,7 @@ OwnPtr<CalculatedStyleValue::CalcNumberProduct> Parser::parse_calc_number_produc
|
|||
{
|
||||
auto calc_number_product = make<CalculatedStyleValue::CalcNumberProduct>(
|
||||
CalculatedStyleValue::CalcNumberValue { Number {} },
|
||||
NonnullOwnPtrVector<CalculatedStyleValue::CalcNumberProductPartWithOperator> {});
|
||||
Vector<NonnullOwnPtr<CalculatedStyleValue::CalcNumberProductPartWithOperator>> {});
|
||||
|
||||
auto first_calc_number_value_or_error = parse_calc_number_value(tokens);
|
||||
if (!first_calc_number_value_or_error.has_value())
|
||||
|
@ -7139,7 +7139,7 @@ OwnPtr<CalculatedStyleValue::CalcNumberSum> Parser::parse_calc_number_sum(TokenS
|
|||
if (!first_calc_number_product_or_error)
|
||||
return nullptr;
|
||||
|
||||
NonnullOwnPtrVector<CalculatedStyleValue::CalcNumberSumPartWithOperator> additional {};
|
||||
Vector<NonnullOwnPtr<CalculatedStyleValue::CalcNumberSumPartWithOperator>> additional {};
|
||||
while (tokens.has_next_token()) {
|
||||
auto calc_sum_part = parse_calc_number_sum_part_with_operator(tokens);
|
||||
if (!calc_sum_part)
|
||||
|
@ -7175,7 +7175,7 @@ OwnPtr<CalculatedStyleValue::CalcProduct> Parser::parse_calc_product(TokenStream
|
|||
{
|
||||
auto calc_product = make<CalculatedStyleValue::CalcProduct>(
|
||||
CalculatedStyleValue::CalcValue { Number {} },
|
||||
NonnullOwnPtrVector<CalculatedStyleValue::CalcProductPartWithOperator> {});
|
||||
Vector<NonnullOwnPtr<CalculatedStyleValue::CalcProductPartWithOperator>> {});
|
||||
|
||||
auto first_calc_value_or_error = parse_calc_value(tokens);
|
||||
if (!first_calc_value_or_error.has_value())
|
||||
|
@ -7225,7 +7225,7 @@ OwnPtr<CalculatedStyleValue::CalcSum> Parser::parse_calc_sum(TokenStream<Compone
|
|||
if (!parsed_calc_product)
|
||||
return nullptr;
|
||||
|
||||
NonnullOwnPtrVector<CalculatedStyleValue::CalcSumPartWithOperator> additional {};
|
||||
Vector<NonnullOwnPtr<CalculatedStyleValue::CalcSumPartWithOperator>> additional {};
|
||||
while (tokens.has_next_token()) {
|
||||
auto calc_sum_part = parse_calc_sum_part_with_operator(tokens);
|
||||
if (!calc_sum_part)
|
||||
|
|
|
@ -602,7 +602,7 @@ ErrorOr<String> CalculatedStyleValue::CalcSum::to_string() const
|
|||
StringBuilder builder;
|
||||
TRY(builder.try_append(TRY(first_calc_product->to_string())));
|
||||
for (auto const& item : zero_or_more_additional_calc_products)
|
||||
TRY(builder.try_append(TRY(item.to_string())));
|
||||
TRY(builder.try_append(TRY(item->to_string())));
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
@ -611,7 +611,7 @@ ErrorOr<String> CalculatedStyleValue::CalcNumberSum::to_string() const
|
|||
StringBuilder builder;
|
||||
TRY(builder.try_append(TRY(first_calc_number_product->to_string())));
|
||||
for (auto const& item : zero_or_more_additional_calc_number_products)
|
||||
TRY(builder.try_append(TRY(item.to_string())));
|
||||
TRY(builder.try_append(TRY(item->to_string())));
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
@ -620,7 +620,7 @@ ErrorOr<String> CalculatedStyleValue::CalcProduct::to_string() const
|
|||
StringBuilder builder;
|
||||
TRY(builder.try_append(TRY(first_calc_value.to_string())));
|
||||
for (auto const& item : zero_or_more_additional_calc_values)
|
||||
TRY(builder.try_append(TRY(item.to_string())));
|
||||
TRY(builder.try_append(TRY(item->to_string())));
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,7 @@ ErrorOr<String> CalculatedStyleValue::CalcNumberProduct::to_string() const
|
|||
StringBuilder builder;
|
||||
TRY(builder.try_append(TRY(first_calc_number_value.to_string())));
|
||||
for (auto const& item : zero_or_more_additional_calc_number_values)
|
||||
TRY(builder.try_append(TRY(item.to_string())));
|
||||
TRY(builder.try_append(TRY(item->to_string())));
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
@ -790,12 +790,12 @@ static bool is_dimension(CalculatedStyleValue::ResolvedType type)
|
|||
}
|
||||
|
||||
template<typename SumWithOperator>
|
||||
static Optional<CalculatedStyleValue::ResolvedType> resolve_sum_type(CalculatedStyleValue::ResolvedType first_type, NonnullOwnPtrVector<SumWithOperator> const& zero_or_more_additional_products)
|
||||
static Optional<CalculatedStyleValue::ResolvedType> resolve_sum_type(CalculatedStyleValue::ResolvedType first_type, Vector<NonnullOwnPtr<SumWithOperator>> const& zero_or_more_additional_products)
|
||||
{
|
||||
auto type = first_type;
|
||||
|
||||
for (auto const& product : zero_or_more_additional_products) {
|
||||
auto maybe_product_type = product.resolved_type();
|
||||
auto maybe_product_type = product->resolved_type();
|
||||
if (!maybe_product_type.has_value())
|
||||
return {};
|
||||
auto product_type = maybe_product_type.value();
|
||||
|
@ -869,17 +869,17 @@ Optional<CalculatedStyleValue::ResolvedType> CalculatedStyleValue::CalcNumberSum
|
|||
}
|
||||
|
||||
template<typename ProductWithOperator>
|
||||
static Optional<CalculatedStyleValue::ResolvedType> resolve_product_type(CalculatedStyleValue::ResolvedType first_type, NonnullOwnPtrVector<ProductWithOperator> const& zero_or_more_additional_values)
|
||||
static Optional<CalculatedStyleValue::ResolvedType> resolve_product_type(CalculatedStyleValue::ResolvedType first_type, Vector<NonnullOwnPtr<ProductWithOperator>> const& zero_or_more_additional_values)
|
||||
{
|
||||
auto type = first_type;
|
||||
|
||||
for (auto const& value : zero_or_more_additional_values) {
|
||||
auto maybe_value_type = value.resolved_type();
|
||||
auto maybe_value_type = value->resolved_type();
|
||||
if (!maybe_value_type.has_value())
|
||||
return {};
|
||||
auto value_type = maybe_value_type.value();
|
||||
|
||||
if (value.op == CalculatedStyleValue::ProductOperation::Multiply) {
|
||||
if (value->op == CalculatedStyleValue::ProductOperation::Multiply) {
|
||||
// At *, check that at least one side is <number>.
|
||||
if (!(is_number(type) || is_number(value_type)))
|
||||
return {};
|
||||
|
@ -894,7 +894,7 @@ static Optional<CalculatedStyleValue::ResolvedType> resolve_product_type(Calcula
|
|||
|
||||
continue;
|
||||
} else {
|
||||
VERIFY(value.op == CalculatedStyleValue::ProductOperation::Divide);
|
||||
VERIFY(value->op == CalculatedStyleValue::ProductOperation::Divide);
|
||||
// At /, check that the right side is <number>.
|
||||
if (!is_number(value_type))
|
||||
return {};
|
||||
|
@ -1005,11 +1005,11 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalcSum::resolve(L
|
|||
auto value = first_calc_product->resolve(layout_node, percentage_basis);
|
||||
|
||||
for (auto& additional_product : zero_or_more_additional_calc_products) {
|
||||
auto additional_value = additional_product.resolve(layout_node, percentage_basis);
|
||||
auto additional_value = additional_product->resolve(layout_node, percentage_basis);
|
||||
|
||||
if (additional_product.op == CalculatedStyleValue::SumOperation::Add)
|
||||
if (additional_product->op == CalculatedStyleValue::SumOperation::Add)
|
||||
value.add(additional_value, layout_node, percentage_basis);
|
||||
else if (additional_product.op == CalculatedStyleValue::SumOperation::Subtract)
|
||||
else if (additional_product->op == CalculatedStyleValue::SumOperation::Subtract)
|
||||
value.subtract(additional_value, layout_node, percentage_basis);
|
||||
else
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -1023,11 +1023,11 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalcNumberSum::res
|
|||
auto value = first_calc_number_product->resolve(layout_node, percentage_basis);
|
||||
|
||||
for (auto& additional_product : zero_or_more_additional_calc_number_products) {
|
||||
auto additional_value = additional_product.resolve(layout_node, percentage_basis);
|
||||
auto additional_value = additional_product->resolve(layout_node, percentage_basis);
|
||||
|
||||
if (additional_product.op == CSS::CalculatedStyleValue::SumOperation::Add)
|
||||
if (additional_product->op == CSS::CalculatedStyleValue::SumOperation::Add)
|
||||
value.add(additional_value, layout_node, percentage_basis);
|
||||
else if (additional_product.op == CalculatedStyleValue::SumOperation::Subtract)
|
||||
else if (additional_product->op == CalculatedStyleValue::SumOperation::Subtract)
|
||||
value.subtract(additional_value, layout_node, percentage_basis);
|
||||
else
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -1041,14 +1041,14 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalcProduct::resol
|
|||
auto value = first_calc_value.resolve(layout_node, percentage_basis);
|
||||
|
||||
for (auto& additional_value : zero_or_more_additional_calc_values) {
|
||||
additional_value.value.visit(
|
||||
additional_value->value.visit(
|
||||
[&](CalculatedStyleValue::CalcValue const& calc_value) {
|
||||
VERIFY(additional_value.op == CalculatedStyleValue::ProductOperation::Multiply);
|
||||
VERIFY(additional_value->op == CalculatedStyleValue::ProductOperation::Multiply);
|
||||
auto resolved_value = calc_value.resolve(layout_node, percentage_basis);
|
||||
value.multiply_by(resolved_value, layout_node);
|
||||
},
|
||||
[&](CalculatedStyleValue::CalcNumberValue const& calc_number_value) {
|
||||
VERIFY(additional_value.op == CalculatedStyleValue::ProductOperation::Divide);
|
||||
VERIFY(additional_value->op == CalculatedStyleValue::ProductOperation::Divide);
|
||||
auto resolved_calc_number_value = calc_number_value.resolve(layout_node, percentage_basis);
|
||||
// FIXME: Checking for division by 0 should happen during parsing.
|
||||
VERIFY(resolved_calc_number_value.value().get<Number>().value() != 0.0f);
|
||||
|
@ -1064,11 +1064,11 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalcNumberProduct:
|
|||
auto value = first_calc_number_value.resolve(layout_node, percentage_basis);
|
||||
|
||||
for (auto& additional_number_value : zero_or_more_additional_calc_number_values) {
|
||||
auto additional_value = additional_number_value.resolve(layout_node, percentage_basis);
|
||||
auto additional_value = additional_number_value->resolve(layout_node, percentage_basis);
|
||||
|
||||
if (additional_number_value.op == CalculatedStyleValue::ProductOperation::Multiply)
|
||||
if (additional_number_value->op == CalculatedStyleValue::ProductOperation::Multiply)
|
||||
value.multiply_by(additional_value, layout_node);
|
||||
else if (additional_number_value.op == CalculatedStyleValue::ProductOperation::Divide)
|
||||
else if (additional_number_value->op == CalculatedStyleValue::ProductOperation::Divide)
|
||||
value.divide_by(additional_value, layout_node);
|
||||
else
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -2290,7 +2290,7 @@ bool CalculatedStyleValue::CalcSum::contains_percentage() const
|
|||
if (first_calc_product->contains_percentage())
|
||||
return true;
|
||||
for (auto& part : zero_or_more_additional_calc_products) {
|
||||
if (part.contains_percentage())
|
||||
if (part->contains_percentage())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -2306,7 +2306,7 @@ bool CalculatedStyleValue::CalcProduct::contains_percentage() const
|
|||
if (first_calc_value.contains_percentage())
|
||||
return true;
|
||||
for (auto& part : zero_or_more_additional_calc_values) {
|
||||
if (part.contains_percentage())
|
||||
if (part->contains_percentage())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -821,12 +821,12 @@ public:
|
|||
|
||||
// This represents that: https://www.w3.org/TR/css-values-3/#calc-syntax
|
||||
struct CalcSum {
|
||||
CalcSum(NonnullOwnPtr<CalcProduct> first_calc_product, NonnullOwnPtrVector<CalcSumPartWithOperator> additional)
|
||||
CalcSum(NonnullOwnPtr<CalcProduct> first_calc_product, Vector<NonnullOwnPtr<CalcSumPartWithOperator>> additional)
|
||||
: first_calc_product(move(first_calc_product))
|
||||
, zero_or_more_additional_calc_products(move(additional)) {};
|
||||
|
||||
NonnullOwnPtr<CalcProduct> first_calc_product;
|
||||
NonnullOwnPtrVector<CalcSumPartWithOperator> zero_or_more_additional_calc_products;
|
||||
Vector<NonnullOwnPtr<CalcSumPartWithOperator>> zero_or_more_additional_calc_products;
|
||||
|
||||
ErrorOr<String> to_string() const;
|
||||
Optional<ResolvedType> resolved_type() const;
|
||||
|
@ -836,12 +836,12 @@ public:
|
|||
};
|
||||
|
||||
struct CalcNumberSum {
|
||||
CalcNumberSum(NonnullOwnPtr<CalcNumberProduct> first_calc_number_product, NonnullOwnPtrVector<CalcNumberSumPartWithOperator> additional)
|
||||
CalcNumberSum(NonnullOwnPtr<CalcNumberProduct> first_calc_number_product, Vector<NonnullOwnPtr<CalcNumberSumPartWithOperator>> additional)
|
||||
: first_calc_number_product(move(first_calc_number_product))
|
||||
, zero_or_more_additional_calc_number_products(move(additional)) {};
|
||||
|
||||
NonnullOwnPtr<CalcNumberProduct> first_calc_number_product;
|
||||
NonnullOwnPtrVector<CalcNumberSumPartWithOperator> zero_or_more_additional_calc_number_products;
|
||||
Vector<NonnullOwnPtr<CalcNumberSumPartWithOperator>> zero_or_more_additional_calc_number_products;
|
||||
|
||||
ErrorOr<String> to_string() const;
|
||||
Optional<ResolvedType> resolved_type() const;
|
||||
|
@ -850,7 +850,7 @@ public:
|
|||
|
||||
struct CalcProduct {
|
||||
CalcValue first_calc_value;
|
||||
NonnullOwnPtrVector<CalcProductPartWithOperator> zero_or_more_additional_calc_values;
|
||||
Vector<NonnullOwnPtr<CalcProductPartWithOperator>> zero_or_more_additional_calc_values;
|
||||
|
||||
ErrorOr<String> to_string() const;
|
||||
Optional<ResolvedType> resolved_type() const;
|
||||
|
@ -885,7 +885,7 @@ public:
|
|||
|
||||
struct CalcNumberProduct {
|
||||
CalcNumberValue first_calc_number_value;
|
||||
NonnullOwnPtrVector<CalcNumberProductPartWithOperator> zero_or_more_additional_calc_number_values;
|
||||
Vector<NonnullOwnPtr<CalcNumberProductPartWithOperator>> zero_or_more_additional_calc_number_values;
|
||||
|
||||
ErrorOr<String> to_string() const;
|
||||
Optional<ResolvedType> resolved_type() const;
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
virtual ~WebAssemblyInstanceObject() override = default;
|
||||
|
||||
size_t index() const { return m_index; }
|
||||
Wasm::ModuleInstance& instance() const { return WebAssemblyObject::s_instantiated_modules.at(m_index); }
|
||||
Wasm::ModuleInstance& instance() const { return *WebAssemblyObject::s_instantiated_modules[m_index]; }
|
||||
auto& cache() { return WebAssemblyObject::s_module_caches.at(m_index); }
|
||||
|
||||
void visit_edges(Visitor&) override;
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
virtual ~WebAssemblyModuleObject() override = default;
|
||||
|
||||
size_t index() const { return m_index; }
|
||||
Wasm::Module const& module() const { return WebAssemblyObject::s_compiled_modules.at(m_index).module; }
|
||||
Wasm::Module const& module() const { return WebAssemblyObject::s_compiled_modules.at(m_index)->module; }
|
||||
|
||||
private:
|
||||
size_t m_index { 0 };
|
||||
|
|
|
@ -58,8 +58,8 @@ JS::ThrowCompletionOr<void> WebAssemblyObject::initialize(JS::Realm& realm)
|
|||
return {};
|
||||
}
|
||||
|
||||
NonnullOwnPtrVector<WebAssemblyObject::CompiledWebAssemblyModule> WebAssemblyObject::s_compiled_modules;
|
||||
NonnullOwnPtrVector<Wasm::ModuleInstance> WebAssemblyObject::s_instantiated_modules;
|
||||
Vector<NonnullOwnPtr<WebAssemblyObject::CompiledWebAssemblyModule>> WebAssemblyObject::s_compiled_modules;
|
||||
Vector<NonnullOwnPtr<Wasm::ModuleInstance>> WebAssemblyObject::s_instantiated_modules;
|
||||
Vector<WebAssemblyObject::ModuleCache> WebAssemblyObject::s_module_caches;
|
||||
WebAssemblyObject::GlobalModuleCache WebAssemblyObject::s_global_cache;
|
||||
Wasm::AbstractMachine WebAssemblyObject::s_abstract_machine;
|
||||
|
@ -101,7 +101,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::validate)
|
|||
};
|
||||
|
||||
// 3 continued - our "compile" step is lazy with validation, explicitly do the validation.
|
||||
if (s_abstract_machine.validate(s_compiled_modules[maybe_module.value()].module).is_error())
|
||||
if (s_abstract_machine.validate(s_compiled_modules[maybe_module.value()]->module).is_error())
|
||||
return JS::Value(false);
|
||||
|
||||
// 4. Return true.
|
||||
|
@ -331,7 +331,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::instantiate)
|
|||
promise->reject(*result.release_error().value());
|
||||
return promise;
|
||||
}
|
||||
module = &WebAssemblyObject::s_compiled_modules.at(result.release_value()).module;
|
||||
module = &WebAssemblyObject::s_compiled_modules.at(result.release_value())->module;
|
||||
should_return_module = true;
|
||||
} else if (is<WebAssemblyModuleObject>(buffer)) {
|
||||
module = &static_cast<WebAssemblyModuleObject*>(buffer)->module();
|
||||
|
|
|
@ -54,8 +54,8 @@ public:
|
|||
HashMap<Wasm::FunctionAddress, JS::NativeFunction*> function_instances;
|
||||
};
|
||||
|
||||
static NonnullOwnPtrVector<CompiledWebAssemblyModule> s_compiled_modules;
|
||||
static NonnullOwnPtrVector<Wasm::ModuleInstance> s_instantiated_modules;
|
||||
static Vector<NonnullOwnPtr<CompiledWebAssemblyModule>> s_compiled_modules;
|
||||
static Vector<NonnullOwnPtr<Wasm::ModuleInstance>> s_instantiated_modules;
|
||||
static Vector<ModuleCache> s_module_caches;
|
||||
static GlobalModuleCache s_global_cache;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ bool Node::operator==(Node const& other) const
|
|||
if (element.children.size() != other_element->children.size())
|
||||
return false;
|
||||
for (size_t i = 0; i < element.children.size(); ++i) {
|
||||
if (element.children[i] != other_element->children[i])
|
||||
if (element.children[i].ptr() != other_element->children[i].ptr())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -30,7 +30,7 @@ struct Node {
|
|||
struct Element {
|
||||
Name name;
|
||||
HashMap<Name, DeprecatedString> attributes;
|
||||
NonnullOwnPtrVector<Node> children;
|
||||
Vector<NonnullOwnPtr<Node>> children;
|
||||
};
|
||||
|
||||
bool operator==(Node const&) const;
|
||||
|
|
|
@ -95,7 +95,7 @@ void Parser::append_text(StringView text)
|
|||
m_entered_node->content.visit(
|
||||
[&](Node::Element& node) {
|
||||
if (!node.children.is_empty()) {
|
||||
auto* text_node = node.children.last().content.get_pointer<Node::Text>();
|
||||
auto* text_node = node.children.last()->content.get_pointer<Node::Text>();
|
||||
if (text_node) {
|
||||
text_node->builder.append(text);
|
||||
return;
|
||||
|
|
|
@ -37,10 +37,10 @@ MCTSTree& MCTSTree::select_leaf()
|
|||
MCTSTree* node = nullptr;
|
||||
double max_uct = -double(INFINITY);
|
||||
for (auto& child : m_children) {
|
||||
double uct = child.uct(m_turn);
|
||||
double uct = child->uct(m_turn);
|
||||
if (uct >= max_uct) {
|
||||
max_uct = uct;
|
||||
node = &child;
|
||||
node = child;
|
||||
}
|
||||
}
|
||||
VERIFY(node);
|
||||
|
@ -68,8 +68,8 @@ MCTSTree& MCTSTree::expand()
|
|||
}
|
||||
|
||||
for (auto& child : m_children) {
|
||||
if (child.m_simulations == 0) {
|
||||
return child;
|
||||
if (child->m_simulations == 0) {
|
||||
return *child;
|
||||
}
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -133,8 +133,8 @@ void MCTSTree::do_round()
|
|||
Optional<MCTSTree&> MCTSTree::child_with_move(Chess::Move chess_move)
|
||||
{
|
||||
for (auto& node : m_children) {
|
||||
if (node.last_move() == chess_move)
|
||||
return node;
|
||||
if (node->last_move() == chess_move)
|
||||
return *node;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ MCTSTree& MCTSTree::best_node()
|
|||
double best_score = -double(INFINITY);
|
||||
VERIFY(m_children.size());
|
||||
for (auto& node : m_children) {
|
||||
double node_score = node.expected_value() * score_multiplier;
|
||||
double node_score = node->expected_value() * score_multiplier;
|
||||
if (node_score >= best_score) {
|
||||
best_node_ptr = &node;
|
||||
best_node_ptr = node;
|
||||
best_score = node_score;
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ bool MCTSTree::expanded() const
|
|||
return false;
|
||||
|
||||
for (auto& child : m_children) {
|
||||
if (child.m_simulations == 0)
|
||||
if (child->m_simulations == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ private:
|
|||
// FIXME: Optimize simulations enough for use.
|
||||
static constexpr EvalMethod s_eval_method { EvalMethod::Heuristic };
|
||||
|
||||
NonnullOwnPtrVector<MCTSTree> m_children;
|
||||
Vector<NonnullOwnPtr<MCTSTree>> m_children;
|
||||
MCTSTree* m_parent { nullptr };
|
||||
int m_white_points { 0 };
|
||||
int m_simulations { 0 };
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace RequestServer::ConnectionCache {
|
||||
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::TCPSocket, Core::Socket>>>> g_tcp_connection_cache {};
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<TLS::TLSv12>>>> g_tls_connection_cache {};
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<Core::TCPSocket, Core::Socket>>>>> g_tcp_connection_cache {};
|
||||
HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<TLS::TLSv12>>>>> g_tls_connection_cache {};
|
||||
|
||||
void request_did_finish(URL const& url, Core::Socket const* socket)
|
||||
{
|
||||
|
@ -85,10 +85,10 @@ void dump_jobs()
|
|||
for (auto& connection : g_tls_connection_cache) {
|
||||
dbgln(" - {}:{}", connection.key.hostname, connection.key.port);
|
||||
for (auto& entry : *connection.value) {
|
||||
dbgln(" - Connection {} (started={}) (socket={})", &entry, entry.has_started, entry.socket);
|
||||
dbgln(" Currently loading {} ({} elapsed)", entry.current_url, entry.timer.is_valid() ? entry.timer.elapsed() : 0);
|
||||
dbgln(" - Connection {} (started={}) (socket={})", &entry, entry->has_started, entry->socket);
|
||||
dbgln(" Currently loading {} ({} elapsed)", entry->current_url, entry->timer.is_valid() ? entry->timer.elapsed() : 0);
|
||||
dbgln(" Request Queue:");
|
||||
for (auto& job : entry.request_queue)
|
||||
for (auto& job : entry->request_queue)
|
||||
dbgln(" - {}", &job);
|
||||
}
|
||||
}
|
||||
|
@ -96,10 +96,10 @@ void dump_jobs()
|
|||
for (auto& connection : g_tcp_connection_cache) {
|
||||
dbgln(" - {}:{}", connection.key.hostname, connection.key.port);
|
||||
for (auto& entry : *connection.value) {
|
||||
dbgln(" - Connection {} (started={}) (socket={})", &entry, entry.has_started, entry.socket);
|
||||
dbgln(" Currently loading {} ({} elapsed)", entry.current_url, entry.timer.is_valid() ? entry.timer.elapsed() : 0);
|
||||
dbgln(" - Connection {} (started={}) (socket={})", &entry, entry->has_started, entry->socket);
|
||||
dbgln(" Currently loading {} ({} elapsed)", entry->current_url, entry->timer.is_valid() ? entry->timer.elapsed() : 0);
|
||||
dbgln(" Request Queue:");
|
||||
for (auto& job : entry.request_queue)
|
||||
for (auto& job : entry->request_queue)
|
||||
dbgln(" - {}", &job);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,8 +121,8 @@ struct AK::Traits<RequestServer::ConnectionCache::ConnectionKey> : public AK::Ge
|
|||
|
||||
namespace RequestServer::ConnectionCache {
|
||||
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::TCPSocket, Core::Socket>>>> g_tcp_connection_cache;
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<TLS::TLSv12>>>> g_tls_connection_cache;
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<Core::TCPSocket, Core::Socket>>>>> g_tcp_connection_cache;
|
||||
extern HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<TLS::TLSv12>>>>> g_tls_connection_cache;
|
||||
|
||||
void request_did_finish(URL const&, Core::Socket const*);
|
||||
void dump_jobs();
|
||||
|
@ -178,12 +178,12 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
|
|||
|
||||
Proxy proxy { proxy_data };
|
||||
|
||||
using ReturnType = decltype(&sockets_for_url[0]);
|
||||
using ReturnType = decltype(sockets_for_url[0].ptr());
|
||||
auto it = sockets_for_url.find_if([](auto& connection) { return connection->request_queue.is_empty(); });
|
||||
auto did_add_new_connection = false;
|
||||
auto failed_to_find_a_socket = it.is_end();
|
||||
if (failed_to_find_a_socket && sockets_for_url.size() < ConnectionCache::MaxConcurrentConnectionsPerURL) {
|
||||
using ConnectionType = RemoveCVReference<decltype(cache.begin()->value->at(0))>;
|
||||
using ConnectionType = RemoveCVReference<decltype(*cache.begin()->value->at(0))>;
|
||||
auto connection_result = proxy.tunnel<typename ConnectionType::SocketType, typename ConnectionType::StorageType>(url);
|
||||
if (connection_result.is_error()) {
|
||||
dbgln("ConnectionCache: Connection to {} failed: {}", url, connection_result.error());
|
||||
|
@ -204,7 +204,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
|
|||
socket_result.release_value(),
|
||||
typename ConnectionType::QueueType {},
|
||||
Core::Timer::create_single_shot(ConnectionKeepAliveTimeMilliseconds, nullptr).release_value_but_fixme_should_propagate_errors()));
|
||||
sockets_for_url.last().proxy = move(proxy);
|
||||
sockets_for_url.last()->proxy = move(proxy);
|
||||
did_add_new_connection = true;
|
||||
}
|
||||
size_t index;
|
||||
|
@ -216,7 +216,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
|
|||
index = 0;
|
||||
auto min_queue_size = (size_t)-1;
|
||||
for (auto it = sockets_for_url.begin(); it != sockets_for_url.end(); ++it) {
|
||||
if (auto queue_size = it->request_queue.size(); min_queue_size > queue_size) {
|
||||
if (auto queue_size = (*it)->request_queue.size(); min_queue_size > queue_size) {
|
||||
index = it.index();
|
||||
min_queue_size = queue_size;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
|
|||
return ReturnType { nullptr };
|
||||
}
|
||||
|
||||
auto& connection = sockets_for_url[index];
|
||||
auto& connection = *sockets_for_url[index];
|
||||
if (!connection.has_started) {
|
||||
if (auto result = recreate_socket_if_needed(connection, url); result.is_error()) {
|
||||
dbgln("ConnectionCache: request failed to start, failed to make a socket: {}", result.error());
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace WebDriver {
|
||||
|
||||
Atomic<unsigned> Client::s_next_session_id;
|
||||
NonnullOwnPtrVector<Session> Client::s_sessions;
|
||||
Vector<NonnullOwnPtr<Session>> Client::s_sessions;
|
||||
|
||||
ErrorOr<NonnullRefPtr<Client>> Client::try_create(NonnullOwnPtr<Core::BufferedTCPSocket> socket, LaunchBrowserCallbacks callbacks, Core::Object* parent)
|
||||
{
|
||||
|
@ -44,8 +44,8 @@ ErrorOr<Session*, Web::WebDriver::Error> Client::find_session_with_id(StringView
|
|||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidSessionId, "Invalid session id");
|
||||
|
||||
for (auto& session : Client::s_sessions) {
|
||||
if (session.session_id() == session_id_or_error.value())
|
||||
return &session;
|
||||
if (session->session_id() == session_id_or_error.value())
|
||||
return session;
|
||||
}
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidSessionId, "Invalid session id");
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ ErrorOr<NonnullOwnPtr<Session>, Web::WebDriver::Error> Client::take_session_with
|
|||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidSessionId, "Invalid session id");
|
||||
|
||||
for (size_t i = 0; i < Client::s_sessions.size(); ++i) {
|
||||
if (Client::s_sessions[i].session_id() == session_id_or_error.value()) {
|
||||
if (Client::s_sessions[i]->session_id() == session_id_or_error.value()) {
|
||||
return Client::s_sessions.take(i);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue