1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 18:38:12 +00:00
serenity/Userland/Libraries/LibJS/Runtime/Intl/Segments.h
Linus Groh ecd163bdf1 LibJS+LibWeb: Replace GlobalObject with Realm in object constructors
No functional changes - we can still very easily get to the global
object via `Realm::global_object()`. This is in preparation of moving
the intrinsics to the realm and no longer having to pass a global
object when allocating any object.
In a few (now, and many more in subsequent commits) places we get a
realm using `GlobalObject::associated_realm()`, this is intended to be
temporary. For example, create() functions will later receive the same
treatment and are passed a realm instead of a global object.
2022-08-23 13:58:30 +01:00

39 lines
991 B
C++

/*
* Copyright (c) 2022, Idan Horowitz <idan.horowitz@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Utf16View.h>
#include <LibJS/Runtime/Intl/Segmenter.h>
#include <LibJS/Runtime/Object.h>
namespace JS::Intl {
class Segments final : public Object {
JS_OBJECT(Segments, Object);
public:
static Segments* create(GlobalObject&, Segmenter&, Utf16String);
Segments(Realm&, Segmenter&, Utf16String);
virtual ~Segments() override = default;
Segmenter& segments_segmenter() const { return m_segments_segmenter; }
Utf16View segments_string() const { return m_segments_string.view(); }
Optional<Vector<size_t>>& boundaries_cache() const { return m_boundaries_cache; }
private:
virtual void visit_edges(Cell::Visitor&) override;
Segmenter& m_segments_segmenter; // [[SegmentsSegmenter]]
Utf16String m_segments_string; // [[SegmentsString]]
mutable Optional<Vector<size_t>> m_boundaries_cache;
};
}