mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 16:58:38 +09:00
[DOM] Convert cleanup of FlushCurrentWord() to a ScopeExit task.
Ensures consistent cleanup even if early exit due to OOM.
This commit is contained in:
parent
e60e1266e9
commit
5ea8de0262
1 changed files with 9 additions and 5 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include "nsHyphenationManager.h"
|
||||
#include "nsHyphenator.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
|
||||
nsLineBreaker::nsLineBreaker()
|
||||
: mCurrentWordLanguage(nullptr),
|
||||
|
|
@ -57,6 +58,14 @@ SetupCapitalization(const char16_t* aWord, uint32_t aLength,
|
|||
nsresult
|
||||
nsLineBreaker::FlushCurrentWord()
|
||||
{
|
||||
auto cleanup = mozilla::MakeScopeExit([&] {
|
||||
mCurrentWord.Clear();
|
||||
mTextItems.Clear();
|
||||
mCurrentWordContainsComplexChar = false;
|
||||
mCurrentWordContainsMixedLang = false;
|
||||
mCurrentWordLanguage = nullptr;
|
||||
});
|
||||
|
||||
uint32_t length = mCurrentWord.Length();
|
||||
AutoTArray<uint8_t,4000> breakState;
|
||||
if (!breakState.AppendElements(length))
|
||||
|
|
@ -137,11 +146,6 @@ nsLineBreaker::FlushCurrentWord()
|
|||
offset += ti->mLength;
|
||||
}
|
||||
|
||||
mCurrentWord.Clear();
|
||||
mTextItems.Clear();
|
||||
mCurrentWordContainsComplexChar = false;
|
||||
mCurrentWordContainsMixedLang = false;
|
||||
mCurrentWordLanguage = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue