| Index: Source/platform/text/BidiResolver.h
|
| diff --git a/Source/platform/text/BidiResolver.h b/Source/platform/text/BidiResolver.h
|
| index 97d3ad496f3362ce5ad5805fc17bb2b91e2be225..64c7bb1f4c9a007898b44445523619111818df41 100644
|
| --- a/Source/platform/text/BidiResolver.h
|
| +++ b/Source/platform/text/BidiResolver.h
|
| @@ -548,18 +548,31 @@ TextDirection BidiResolver<Iterator, Run>::determineParagraphDirectionality(bool
|
| }
|
| if (m_current.atParagraphSeparator())
|
| break;
|
| - if (UChar current = m_current.current()) {
|
| - WTF::Unicode::Direction charDirection = WTF::Unicode::direction(current);
|
| - if (charDirection == WTF::Unicode::LeftToRight) {
|
| - if (hasStrongDirectionality)
|
| - *hasStrongDirectionality = true;
|
| - return LTR;
|
| - }
|
| - if (charDirection == WTF::Unicode::RightToLeft || charDirection == WTF::Unicode::RightToLeftArabic) {
|
| - if (hasStrongDirectionality)
|
| - *hasStrongDirectionality = true;
|
| - return RTL;
|
| - }
|
| + UChar32 current = m_current.current();
|
| + if (UNLIKELY(U16_IS_SURROGATE(current))) {
|
| + increment();
|
| + // If this not the high part of the surrogate pair, then drop it and move to the next.
|
| + if (!U16_IS_SURROGATE_LEAD(current))
|
| + continue;
|
| + UChar high = static_cast<UChar>(current);
|
| + if (m_current.atEnd())
|
| + continue;
|
| + UChar low = m_current.current();
|
| + // Verify the low part. If invalid, then assume an invalid surrogate pair and retry.
|
| + if (!U16_IS_TRAIL(low))
|
| + continue;
|
| + current = U16_GET_SUPPLEMENTARY(high, low);
|
| + }
|
| + WTF::Unicode::Direction charDirection = WTF::Unicode::direction(current);
|
| + if (charDirection == WTF::Unicode::LeftToRight) {
|
| + if (hasStrongDirectionality)
|
| + *hasStrongDirectionality = true;
|
| + return LTR;
|
| + }
|
| + if (charDirection == WTF::Unicode::RightToLeft || charDirection == WTF::Unicode::RightToLeftArabic) {
|
| + if (hasStrongDirectionality)
|
| + *hasStrongDirectionality = true;
|
| + return RTL;
|
| }
|
| increment();
|
| }
|
|
|