From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- js/src/builtin/DataViewObject.h | 43 ++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) (limited to 'js/src/builtin/DataViewObject.h') diff --git a/js/src/builtin/DataViewObject.h b/js/src/builtin/DataViewObject.h index a17b3e1174..db134a5696 100644 --- a/js/src/builtin/DataViewObject.h +++ b/js/src/builtin/DataViewObject.h @@ -48,7 +48,7 @@ class DataViewObject : public ArrayBufferViewObject { const CallArgs& args, size_t* byteOffsetPtr, size_t* byteLengthPtr, - bool* autoLengthPtr); + AutoLength* autoLengthPtr); static bool constructSameCompartment(JSContext* cx, HandleObject bufobj, const CallArgs& args); static bool constructWrapped(JSContext* cx, HandleObject bufobj, @@ -58,16 +58,16 @@ class DataViewObject : public ArrayBufferViewObject { JSContext* cx, size_t byteOffset, size_t byteLength, Handle arrayBuffer, HandleObject proto); - protected: - size_t rawByteLength() const { - return size_t(getFixedSlot(LENGTH_SLOT).toPrivate()); - } - public: static const JSClass protoClass_; - mozilla::Maybe byteLength(); - mozilla::Maybe byteOffset(); + /** + * Return the current byteLength, or |Nothing| if the DataView is detached or + * out-of-bounds. + */ + mozilla::Maybe byteLength() { + return ArrayBufferViewObject::length(); + } template static bool offsetIsInBounds(uint64_t offset, size_t byteLength) { @@ -173,19 +173,11 @@ class FixedLengthDataViewObject : public DataViewObject { public: static const JSClass class_; - size_t byteOffset() const { return ArrayBufferViewObject::byteOffset(); } - - size_t byteLength() const { return rawByteLength(); } - - bool offsetIsInBounds(uint32_t byteSize, uint64_t offset) const { - return DataViewObject::offsetIsInBounds(byteSize, offset, byteLength()); + size_t byteOffset() const { + return ArrayBufferViewObject::byteOffsetSlotValue(); } - template - NativeType read(uint64_t offset, bool isLittleEndian) { - return DataViewObject::read(offset, byteLength(), - isLittleEndian); - } + size_t byteLength() const { return ArrayBufferViewObject::lengthSlotValue(); } }; /** @@ -195,19 +187,14 @@ class ResizableDataViewObject : public DataViewObject { friend class DataViewObject; static ResizableDataViewObject* create( - JSContext* cx, size_t byteOffset, size_t byteLength, bool autoLength, - Handle arrayBuffer, HandleObject proto); + JSContext* cx, size_t byteOffset, size_t byteLength, + AutoLength autoLength, Handle arrayBuffer, + HandleObject proto); public: - static const uint8_t AUTO_LENGTH_SLOT = DataViewObject::RESERVED_SLOTS; - - static const uint8_t RESERVED_SLOTS = DataViewObject::RESERVED_SLOTS + 1; + static const uint8_t RESERVED_SLOTS = RESIZABLE_RESERVED_SLOTS; static const JSClass class_; - - bool isAutoLength() const { - return getFixedSlot(AUTO_LENGTH_SLOT).toBoolean(); - } }; // For structured cloning. -- cgit v1.2.3