The main use of this method appears to be when parsing attributes with floating
point values in HTML. By changing from PR_strtod, this change does have some
semantic differences around edge-cases, though I've tried to keep it compliant
with the wording in the standard.
Here are some of the edge-cases I investigated:
1. We appear to build nspr with INFNAN_CHECK undefined, meaning that we did not
parse strings like "inf", "infinity" and "nan" both before and after this
change.
2. PR_strtod already ignored locale (built with USE_LOCALE undefined), so
locale behaviour shouldn't have changed.
3. Neither PR_strtod nor the spec support hex floats, so I didn't enable them
in double-conversion.
4. Leading whitespace is skipped by both PR_strtod and in the spec, so is
skipped after this change.
5. Numbers too large to fit in a double (e.g. 2E308) were previously returned
as inf or -inf by PR_strtod. The spec specifies that these values should return
an error instead, so they have been changed to produce an error with this
change.
This is a web-visible change (<progress value=2E308 max=10> is indeterminate
in Chromium and complete in Firefox before this change, it will be
indeterminate for both after the change).
6. Parsing for floats & doubles are now handled seperately due to
differences in the maximum and minimum representable values.
Differential Revision: https://phabricator.services.mozilla.com/D148305
This will make customizing flags on the regex type less error-prone, as passing
a flag (e.g. `RustRegex::FLAG_CASEI`) will not implicitly disable the default
`UNICODE` flag.
Names and comments were taken from the original `RegexBuilder` type in the
`regex` crate which this type is inspired by, and the type was changed to be
cheaply copyable and support method chaining, so that it can be used more
ergonomically.
Differential Revision: https://phabricator.services.mozilla.com/D159083
This makes the API more ergonomic to use from our c++ code, managing things
like lifecycles automatically.
Documentation comments are copied from the `rure.h` header, and modified
slightly to reflect the C++ types.
Differential Revision: https://phabricator.services.mozilla.com/D158874
This will make customizing flags on the regex type less error-prone, as passing
a flag (e.g. `RustRegex::FLAG_CASEI`) will not implicitly disable the default
`UNICODE` flag.
Names and comments were taken from the original `RegexBuilder` type in the
`regex` crate which this type is inspired by, and the type was changed to be
cheaply copyable and support method chaining, so that it can be used more
ergonomically.
Differential Revision: https://phabricator.services.mozilla.com/D159083
This makes the API more ergonomic to use from our c++ code, managing things
like lifecycles automatically.
Documentation comments are copied from the `rure.h` header, and modified
slightly to reflect the C++ types.
Differential Revision: https://phabricator.services.mozilla.com/D158874
This will make customizing flags on the regex type less error-prone, as passing
a flag (e.g. `RustRegex::FLAG_CASEI`) will not implicitly disable the default
`UNICODE` flag.
Names and comments were taken from the original `RegexBuilder` type in the
`regex` crate which this type is inspired by, and the type was changed to be
cheaply copyable and support method chaining, so that it can be used more
ergonomically.
Depends on D158874
Differential Revision: https://phabricator.services.mozilla.com/D159083
This makes the API more ergonomic to use from our c++ code, managing things
like lifecycles automatically.
Documentation comments are copied from the `rure.h` header, and modified
slightly to reflect the C++ types.
Differential Revision: https://phabricator.services.mozilla.com/D158874
There are only 3 places where nsMemory.h is still needed (image/RasterImage.cpp,
gfx/thebes/gfxFT2FontList.cpp, and nsMemory.cpp). Remove the rest.
Differential Revision: https://phabricator.services.mozilla.com/D158213
The last remaining things requiring unified builds in this directory are the
explicit specializations. As each class' methods are now confined to a single
file, these can now be moved to the appropriate .cpp files.
Differential Revision: https://phabricator.services.mozilla.com/D148303
These files exist only due to the history of how strings were previously
declared using macros, and aren't necessary anymore. The header files were not
removed, as they may be depended on from outside of the module. Cleaning up the
header situation is something which should probably happen in a follow-up.
Differential Revision: https://phabricator.services.mozilla.com/D148302
The remaining methods in ns[T]StringObsolete are all find+replace methods for
nsTSubstring. These were migrated in a similar way to the find methods, and
partially updated to avoid using methods from nsStringObsolete.cpp.
This change removes the ns[T]StringObsolete.cpp files completely, as they are
no longer necessary.
Differential Revision: https://phabricator.services.mozilla.com/D148301
The biggest set of APIs from ns[T]StringObsolete which are still heavily used
are the string searching APIs. It appears the intention was for these to be
replaced by the `FindInReadable` APIs, however that doesn't appear to have
happened.
In addition, the APIs have some quirks around their handling of mixed character
widths. These APIs generally supported both narrow strings and the native
string type, probably because char16_t string literals weren't available until
c++11. Finally they also used easy-to-confuse unlabeled boolean and integer
optional arguments to control behaviour.
These patches do the following major changes to the searching APIs:
1. The ASCII case-insensitive search method was split out as
LowerCaseFindASCII, rather than using a boolean. This should be less
error-prone and more explicit, and allows the method to continue to use
narrow string literals for all string types (as only ASCII is supported).
2. The other [R]Find methods were restricted to only support arguments with
matching character types. I considered adding a FindASCII method which would
use narrow string literals for both wide and narrow strings but it would've
been the same amount of work as changing all of the literals to unicode
literals.
This ends up being the bulk of the changes in the patch.
3. All find methods were re-implemented using std::basic_string_view's find
algorithm or stl algorithms to reduce code complexity, and avoid the need to
carry around the logic from nsStringObsolete.cpp.
4. The implementations were moved to nsTStringRepr.cpp.
5. An overload of Find was added to try to catch callers which previously
called `Find(..., false)` or `Find(..., true)` to set case-sensitivity, due
to booleans normally implicitly coercing to `index_type`. This should
probably be removed at some point, but may be useful during the transition.
Differential Revision: https://phabricator.services.mozilla.com/D148300
This patch moves EqualsIgnoreCase to ns[T]StringObsolete, and removes
the aCount argument, instead migrating callers to use `StringBeginsWith`
with a case-insensitive comparator.
In addition, nsTStringRepr::Compare was removed and replaced with either
calls to methods like `StringBeginsWith` or the global `Compare` method.
These changes required some modifications at call-sites but should make
the behaviour less surprising and more consistent.
Differential Revision: https://phabricator.services.mozilla.com/D148299
Due to the history of how nsString was implemented, many APIs ended up being
implemented in inappropriate files. This change moves simple definitions which
won't require any changes for each type to happen within that type's .cpp file.
This is necessary to eventually enable the directory to be built without
unified builds.
Differential Revision: https://phabricator.services.mozilla.com/D148298
This type was introduced in c++17, and can be used as a convenient standard
medium for passing around borrowed substring references. It can be implicitly
converted to from string literals and `const char_type*`, meaning that after
this change it can be used as a convenient catch-all type to replace seperate
overloads for `const self_type&`, `const char_type*` and `const
char_type(&)[N]`.
std::basic_string_view also provides standard implementations of some
algorithms which will be convenient for code cleanup in later parts of this
bug.
Differential Revision: https://phabricator.services.mozilla.com/D148297
This file only exists as a wrapper around nsTSubstring.cpp, with some methods
left in it due to how the string types were defined before they were turned
into templates.
Differential Revision: https://phabricator.services.mozilla.com/D148296
The last remaining things requiring unified builds in this directory are the
explicit specializations. As each class' methods are now confined to a single
file, these can now be moved to the appropriate .cpp files.
Differential Revision: https://phabricator.services.mozilla.com/D148303
These files exist only due to the history of how strings were previously
declared using macros, and aren't necessary anymore. The header files were not
removed, as they may be depended on from outside of the module. Cleaning up the
header situation is something which should probably happen in a follow-up.
Differential Revision: https://phabricator.services.mozilla.com/D148302
The remaining methods in ns[T]StringObsolete are all find+replace methods for
nsTSubstring. These were migrated in a similar way to the find methods, and
partially updated to avoid using methods from nsStringObsolete.cpp.
This change removes the ns[T]StringObsolete.cpp files completely, as they are
no longer necessary.
Differential Revision: https://phabricator.services.mozilla.com/D148301
The biggest set of APIs from ns[T]StringObsolete which are still heavily used
are the string searching APIs. It appears the intention was for these to be
replaced by the `FindInReadable` APIs, however that doesn't appear to have
happened.
In addition, the APIs have some quirks around their handling of mixed character
widths. These APIs generally supported both narrow strings and the native
string type, probably because char16_t string literals weren't available until
c++11. Finally they also used easy-to-confuse unlabeled boolean and integer
optional arguments to control behaviour.
These patches do the following major changes to the searching APIs:
1. The ASCII case-insensitive search method was split out as
LowerCaseFindASCII, rather than using a boolean. This should be less
error-prone and more explicit, and allows the method to continue to use
narrow string literals for all string types (as only ASCII is supported).
2. The other [R]Find methods were restricted to only support arguments with
matching character types. I considered adding a FindASCII method which would
use narrow string literals for both wide and narrow strings but it would've
been the same amount of work as changing all of the literals to unicode
literals.
This ends up being the bulk of the changes in the patch.
3. All find methods were re-implemented using std::basic_string_view's find
algorithm or stl algorithms to reduce code complexity, and avoid the need to
carry around the logic from nsStringObsolete.cpp.
4. The implementations were moved to nsTStringRepr.cpp.
5. An overload of Find was added to try to catch callers which previously
called `Find(..., false)` or `Find(..., true)` to set case-sensitivity, due
to booleans normally implicitly coercing to `index_type`. This should
probably be removed at some point, but may be useful during the transition.
Differential Revision: https://phabricator.services.mozilla.com/D148300
In addition to moving these methods to a more appropriate file, they were
simplified to make them easier to maintain in the future.
nsTStringRepr::Compare was extended to also work on char16_t strings, and the
case insensitive and other options were removed as they aren't necessary. This
required some changes to callers in the tree.
The EqualsIgnoreCase method was also simplified by using `std::string_view`.
Differential Revision: https://phabricator.services.mozilla.com/D148299
Due to the history of how nsString was implemented, many APIs ended up being
implemented in inappropriate files. This change moves simple definitions which
won't require any changes for each type to happen within that type's .cpp file.
This is necessary to eventually enable the directory to be built without
unified builds.
Differential Revision: https://phabricator.services.mozilla.com/D148298
This type was introduced in c++17, and can be used as a convenient standard
medium for passing around borrowed substring references. It can be implicitly
converted to from string literals and `const char_type*`, meaning that after
this change it can be used as a convenient catch-all type to replace seperate
overloads for `const self_type&`, `const char_type*` and `const
char_type(&)[N]`.
std::basic_string_view also provides standard implementations of some
algorithms which will be convenient for code cleanup in later parts of this
bug.
Differential Revision: https://phabricator.services.mozilla.com/D148297
This file only exists as a wrapper around nsTSubstring.cpp, with some methods
left in it due to how the string types were defined before they were turned
into templates.
Differential Revision: https://phabricator.services.mozilla.com/D148296
No reason these don't work on substrings.
Remove StripChars since it has an existing nsTSubstring version. Make
callers use rightly-typed characters for those.
Differential Revision: https://phabricator.services.mozilla.com/D145864
Add `NS_ConvertUTF16toUTF8::NS_ConvertUTF16toUTF8(const Span<const char16_t>)` and `NS_ConvertUTF16toUTF8::NS_ConvertUTF8toUTF16(const Span<const char>)` explicit constructors.
This is consistent with `NS_ConvertASCIItoUTF16` that already had one.
More importantly, other constructors were calling `AppendUTF{16,8}To{8,16}` functions taking a `Span`, so for cases where the caller already has a `Span` it's most efficient to have constructors accepting that `Span` directly.
Differential Revision: https://phabricator.services.mozilla.com/D125146
Automatically generated path that adds flag `REQUIRES_UNIFIED_BUILD = True` to `moz.build`
when the module governed by the build config file is not buildable outside on the unified environment.
This needs to be done in order to have a hybrid build system that adds the possibility of combing
unified build components with ones that are built outside of the unified eco system.
Differential Revision: https://phabricator.services.mozilla.com/D122345