diff --git a/dom/base/nsLineBreaker.cpp b/dom/base/nsLineBreaker.cpp index 39041f221a977..46a644588ff91 100644 --- a/dom/base/nsLineBreaker.cpp +++ b/dom/base/nsLineBreaker.cpp @@ -282,274 +282,6 @@ intl : WordBreakRule ; -/ -/ -There -is -no -break -opportunity -between -any -pair -of -characters -that -has -line -/ -/ -break -class -of -either -AL -( -Alphabetic -) -IS -( -Infix -Numeric -Separator -) -NU -/ -/ -( -Numeric -) -or -QU -( -Quotation -) -. -See -/ -/ -https -: -/ -/ -www -. -unicode -. -org -/ -Public -/ -UCD -/ -latest -/ -ucd -/ -LineBreak -. -txt -for -Unicode -code -/ -/ -point -and -line -break -class -mapping -. -static -constexpr -uint8_t -kNonBreakableASCII -[ -] -= -{ -/ -/ -clang -- -format -off -/ -/ -0x20 -- -0x2f -0 -0 -1 -1 -0 -0 -1 -1 -0 -0 -1 -0 -1 -0 -1 -0 -/ -/ -0x30 -- -0x3f -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -/ -/ -0x40 -- -0x4f -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -/ -/ -0x50 -- -0x5f -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -1 -1 -/ -/ -0x60 -- -0x6f -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -/ -/ -0x70 -- -0x7f -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 -0 -0 -1 -0 -/ -/ -clang -- -format -on -} -; -template -< -typename -T -> -static -constexpr -bool -IsNonBreakableChar -( -T -aChar -) -{ -if -( -aChar -< -0x20 -| -| -aChar -> -0x7f -) -{ -return -false -; -} -return -! -! -kNonBreakableASCII -[ -aChar -- -0x20 -] -; -} nsLineBreaker : : @@ -565,6 +297,10 @@ mCurrentWordContainsMixedLang ( false ) +mCurrentWordContainsComplexChar +( +false +) mScriptIsChineseOrJapanese ( false @@ -1137,7 +873,7 @@ else if ( ! -mCurrentWordMightBeBreakable +mCurrentWordContainsComplexChar ) { / @@ -1710,7 +1446,7 @@ Clear ( ) ; -mCurrentWordMightBeBreakable +mCurrentWordContainsComplexChar = false ; @@ -1882,14 +1618,10 @@ offset if ( ! -mCurrentWordMightBeBreakable +mCurrentWordContainsComplexChar & & -! -IsNonBreakableChar -< -char16_t -> +IsComplexChar ( aText [ @@ -1898,7 +1630,7 @@ offset ) ) { -mCurrentWordMightBeBreakable +mCurrentWordContainsComplexChar = true ; @@ -2221,7 +1953,7 @@ wordStart offset ; bool -wordMightBeBreakable +wordHasComplexChar = false ; @@ -2440,7 +2172,7 @@ wordStart else if ( -wordMightBeBreakable +wordHasComplexChar ) { / @@ -2555,7 +2287,7 @@ wordStart ; } } -wordMightBeBreakable +wordHasComplexChar = false ; @@ -2582,26 +2314,22 @@ wordStart = offset ; -continue -; } +else +{ if ( ! -wordMightBeBreakable +wordHasComplexChar & & -! -IsNonBreakableChar -< -char16_t -> +IsComplexChar ( ch ) ) { -wordMightBeBreakable +wordHasComplexChar = true ; @@ -2623,9 +2351,9 @@ aLength Save this word -mCurrentWordMightBeBreakable +mCurrentWordContainsComplexChar = -wordMightBeBreakable +wordHasComplexChar ; uint32_t len @@ -2643,10 +2371,6 @@ mCurrentWord AppendElements ( len -mozilla -: -: -fallible ) ; if @@ -2715,6 +2439,7 @@ break ; } } +} if ( aSink @@ -3050,14 +2775,10 @@ offset if ( ! -mCurrentWordMightBeBreakable +mCurrentWordContainsComplexChar & & -! -IsNonBreakableChar -< -uint8_t -> +IsComplexASCIIChar ( aText [ @@ -3066,7 +2787,7 @@ offset ) ) { -mCurrentWordMightBeBreakable +mCurrentWordContainsComplexChar = true ; @@ -3320,7 +3041,7 @@ wordStart offset ; bool -wordMightBeBreakable +wordHasComplexChar = false ; @@ -3514,7 +3235,7 @@ wordStart else if ( -wordMightBeBreakable +wordHasComplexChar ) { / @@ -3576,7 +3297,7 @@ wordStart ; } } -wordMightBeBreakable +wordHasComplexChar = false ; @@ -3603,26 +3324,22 @@ wordStart = offset ; -continue -; } +else +{ if ( ! -wordMightBeBreakable +wordHasComplexChar & & -! -IsNonBreakableChar -< -uint8_t -> +IsComplexASCIIChar ( ch ) ) { -wordMightBeBreakable +wordHasComplexChar = true ; @@ -3644,9 +3361,9 @@ aLength Save this word -mCurrentWordMightBeBreakable +mCurrentWordContainsComplexChar = -wordMightBeBreakable +wordHasComplexChar ; uint32_t len @@ -3664,10 +3381,6 @@ mCurrentWord AppendElements ( len -mozilla -: -: -fallible ) ; if @@ -3748,6 +3461,7 @@ break ; } } +} if ( ! diff --git a/dom/base/nsLineBreaker.h b/dom/base/nsLineBreaker.h index cae56d26d71fb..a237a253be1b5 100644 --- a/dom/base/nsLineBreaker.h +++ b/dom/base/nsLineBreaker.h @@ -509,15 +509,22 @@ to the LineBreaker * +service for deeper analysis if they -might contain -breakable -characters +a +" +complex +" +character +as +* +described +below . * * @@ -596,6 +603,192 @@ u ) ; } +static +inline +bool +IsComplexASCIIChar +( +char16_t +u +) +{ +return +! +( +( +0x0030 +< += +u +& +& +u +< += +0x0039 +) +| +| +( +0x0041 +< += +u +& +& +u +< += +0x005A +) +| +| +( +0x0061 +< += +u +& +& +u +< += +0x007A +) +| +| +( +0x000a += += +u +) +) +; +} +static +inline +bool +IsComplexChar +( +char16_t +u +) +{ +return +IsComplexASCIIChar +( +u +) +| +| +mozilla +: +: +intl +: +: +NS_NeedsPlatformNativeHandling +( +u +) +| +| +( +0x1100 +< += +u +& +& +u +< += +0x11ff +) +| +| +/ +/ +Hangul +Jamo +( +0x2000 +< += +u +& +& +u +< += +0x21ff +) +| +| +/ +/ +Punctuations +and +Symbols +( +0x2e80 +< += +u +& +& +u +< += +0xd7ff +) +| +| +/ +/ +several +CJK +blocks +( +0xf900 +< += +u +& +& +u +< += +0xfaff +) +| +| +/ +/ +CJK +Compatibility +Idographs +( +0xff00 +< += +u +& +& +u +< += +0xffef +) +; +/ +/ +Halfwidth +and +Fullwidth +Forms +} / / Break @@ -665,12 +858,8 @@ one character / / -that -has -breakable -line -breaking -classes +matching +IsComplexChar . / / @@ -1901,9 +2090,7 @@ bool mCurrentWordContainsMixedLang ; bool -mCurrentWordMightBeBreakable -= -false +mCurrentWordContainsComplexChar ; bool mScriptIsChineseOrJapanese