mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
AK+Everywhere: Make UTF-8 and UTF-32 to UTF-16 converters fallible
These could fail to allocate the underlying storage needed to store the UTF-16 data. Propagate these errors.
This commit is contained in:
parent
d8044c5358
commit
1edb96376b
13 changed files with 46 additions and 35 deletions
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
|
||||
#include <AK/Utf16View.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Utf16String.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/SVG/SVGTextContentElement.h>
|
||||
|
||||
|
@ -17,9 +19,10 @@ SVGTextContentElement::SVGTextContentElement(DOM::Document& document, DOM::Quali
|
|||
}
|
||||
|
||||
// https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getNumberOfChars
|
||||
int SVGTextContentElement::get_number_of_chars() const
|
||||
WebIDL::ExceptionOr<int> SVGTextContentElement::get_number_of_chars() const
|
||||
{
|
||||
return AK::utf8_to_utf16(child_text_content()).size();
|
||||
auto chars = TRY_OR_THROW_OOM(vm(), utf8_to_utf16(child_text_content()));
|
||||
return static_cast<int>(chars.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue