mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb: Add Document helpers to move its cursor to word boundaries
This implementation is based on the same feature I added to Serenity's TextEditor: https://github.com/SerenityOS/serenity/pull/17477
This commit is contained in:
parent
eece7697fd
commit
ecf2cc600b
Notes:
github-actions[bot]
2024-09-06 05:44:05 +00:00
Author: https://github.com/trflynn89
Commit: ecf2cc600b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1292
6 changed files with 92 additions and 0 deletions
|
@ -130,6 +130,8 @@ WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t coun
|
|||
|
||||
if (m_grapheme_segmenter)
|
||||
m_grapheme_segmenter->set_segmented_text(m_data);
|
||||
if (m_word_segmenter)
|
||||
m_word_segmenter->set_segmented_text(m_data);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -165,4 +167,14 @@ Unicode::Segmenter& CharacterData::grapheme_segmenter()
|
|||
return *m_grapheme_segmenter;
|
||||
}
|
||||
|
||||
Unicode::Segmenter& CharacterData::word_segmenter()
|
||||
{
|
||||
if (!m_word_segmenter) {
|
||||
m_word_segmenter = Unicode::Segmenter::create(Unicode::SegmenterGranularity::Word);
|
||||
m_word_segmenter->set_segmented_text(m_data);
|
||||
}
|
||||
|
||||
return *m_word_segmenter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue