mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +00:00
LibWeb: Port text segmentation to the ICU text segmenter
This commit is contained in:
parent
14071c52f9
commit
12f177e9e9
Notes:
sideshowbarker
2024-07-17 03:27:40 +09:00
Author: https://github.com/trflynn89
Commit: 12f177e9e9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/218
5 changed files with 40 additions and 20 deletions
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibUnicode/Segmentation.h>
|
||||
#include <LibLocale/Segmenter.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/Position.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
|
@ -40,9 +40,8 @@ bool Position::increment_offset()
|
|||
return false;
|
||||
|
||||
auto& node = verify_cast<DOM::Text>(*m_node);
|
||||
auto text = Utf8View(node.data());
|
||||
|
||||
if (auto offset = Unicode::next_grapheme_segmentation_boundary(text, m_offset); offset.has_value()) {
|
||||
if (auto offset = node.segmenter().next_boundary(m_offset); offset.has_value()) {
|
||||
m_offset = *offset;
|
||||
return true;
|
||||
}
|
||||
|
@ -57,9 +56,8 @@ bool Position::decrement_offset()
|
|||
return false;
|
||||
|
||||
auto& node = verify_cast<DOM::Text>(*m_node);
|
||||
auto text = Utf8View(node.data());
|
||||
|
||||
if (auto offset = Unicode::previous_grapheme_segmentation_boundary(text, m_offset); offset.has_value()) {
|
||||
if (auto offset = node.segmenter().previous_boundary(m_offset); offset.has_value()) {
|
||||
m_offset = *offset;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue