mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +00:00
LibJS: Compute NumberFormat's rounding priority during construction
This is an editorial change in the ECMA-402 spec. See:
c28118e
This commit is contained in:
parent
bc8c2b2bc2
commit
b0c8543b28
4 changed files with 53 additions and 30 deletions
|
@ -29,6 +29,13 @@ public:
|
|||
LessPrecision,
|
||||
};
|
||||
|
||||
enum class ComputedRoundingPriority {
|
||||
Invalid,
|
||||
Auto,
|
||||
MorePrecision,
|
||||
LessPrecision,
|
||||
};
|
||||
|
||||
enum class RoundingMode {
|
||||
Invalid,
|
||||
Ceil,
|
||||
|
@ -87,6 +94,10 @@ public:
|
|||
StringView rounding_type_string() const;
|
||||
void set_rounding_type(RoundingType rounding_type) { m_rounding_type = rounding_type; }
|
||||
|
||||
ComputedRoundingPriority computed_rounding_priority() const { return m_computed_rounding_priority; }
|
||||
StringView computed_rounding_priority_string() const;
|
||||
void set_computed_rounding_priority(ComputedRoundingPriority computed_rounding_priority) { m_computed_rounding_priority = computed_rounding_priority; }
|
||||
|
||||
RoundingMode rounding_mode() const { return m_rounding_mode; }
|
||||
StringView rounding_mode_string() const;
|
||||
void set_rounding_mode(StringView rounding_mode);
|
||||
|
@ -102,17 +113,18 @@ protected:
|
|||
explicit NumberFormatBase(Object& prototype);
|
||||
|
||||
private:
|
||||
String m_locale; // [[Locale]]
|
||||
String m_data_locale; // [[DataLocale]]
|
||||
int m_min_integer_digits { 0 }; // [[MinimumIntegerDigits]]
|
||||
Optional<int> m_min_fraction_digits {}; // [[MinimumFractionDigits]]
|
||||
Optional<int> m_max_fraction_digits {}; // [[MaximumFractionDigits]]
|
||||
Optional<int> m_min_significant_digits {}; // [[MinimumSignificantDigits]]
|
||||
Optional<int> m_max_significant_digits {}; // [[MaximumSignificantDigits]]
|
||||
RoundingType m_rounding_type { RoundingType::Invalid }; // [[RoundingType]]
|
||||
RoundingMode m_rounding_mode { RoundingMode::Invalid }; // [[RoundingMode]]
|
||||
int m_rounding_increment { 1 }; // [[RoundingIncrement]]
|
||||
TrailingZeroDisplay m_trailing_zero_display { TrailingZeroDisplay::Invalid }; // [[TrailingZeroDisplay]]
|
||||
String m_locale; // [[Locale]]
|
||||
String m_data_locale; // [[DataLocale]]
|
||||
int m_min_integer_digits { 0 }; // [[MinimumIntegerDigits]]
|
||||
Optional<int> m_min_fraction_digits {}; // [[MinimumFractionDigits]]
|
||||
Optional<int> m_max_fraction_digits {}; // [[MaximumFractionDigits]]
|
||||
Optional<int> m_min_significant_digits {}; // [[MinimumSignificantDigits]]
|
||||
Optional<int> m_max_significant_digits {}; // [[MaximumSignificantDigits]]
|
||||
RoundingType m_rounding_type { RoundingType::Invalid }; // [[RoundingType]]
|
||||
ComputedRoundingPriority m_computed_rounding_priority { ComputedRoundingPriority::Invalid }; // [[ComputedRoundingPriority]]
|
||||
RoundingMode m_rounding_mode { RoundingMode::Invalid }; // [[RoundingMode]]
|
||||
int m_rounding_increment { 1 }; // [[RoundingIncrement]]
|
||||
TrailingZeroDisplay m_trailing_zero_display { TrailingZeroDisplay::Invalid }; // [[TrailingZeroDisplay]]
|
||||
};
|
||||
|
||||
class NumberFormat final : public NumberFormatBase {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue