Bug 196175 - patch 2 - Override category of underscore for word-selection purposes so it is treated as a word-forming character, and update word-movement tests accordingly. r=m_kato

This commit is contained in:
Jonathan Kew 2018-01-03 10:02:39 +00:00
parent e1b6122dbc
commit 9d2a5668d2
3 changed files with 7 additions and 14 deletions

View File

@ -53,7 +53,7 @@ WordBreaker::GetClass(char16_t c)
if(IS_ASCII(c)) {
if(ASCII_IS_SPACE(c)) {
return kWbClassSpace;
} else if(ASCII_IS_ALPHA(c) || ASCII_IS_DIGIT(c)) {
} else if(ASCII_IS_ALPHA(c) || ASCII_IS_DIGIT(c) || c == '_') {
return kWbClassAlphaLetter;
} else {
return kWbClassPunct;

View File

@ -8117,9 +8117,14 @@ ClusterIterator::IsPunctuation()
// Return true for all Punctuation categories (Unicode general category P?),
// and also for Symbol categories (S?) except for Modifier Symbol, which is
// kept together with any adjacent letter/number. (Bug 1066756)
uint8_t cat = unicode::GetGeneralCategory(mFrag->CharAt(mCharIndex));
uint32_t ch = mFrag->CharAt(mCharIndex);
uint8_t cat = unicode::GetGeneralCategory(ch);
switch (cat) {
case HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION: /* Pc */
if (ch == '_') {
return false;
}
MOZ_FALLTHROUGH;
case HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION: /* Pd */
case HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION: /* Pe */
case HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION: /* Pf */

View File

@ -130,15 +130,9 @@ function test1() {
editor.innerHTML = "layout.word_select.stop_at_punctuation";
sel.collapse(editor.firstChild, 0);
testRight(editor.firstChild, 7);
testRight(editor.firstChild, 12);
testRight(editor.firstChild, 19);
testRight(editor.firstChild, 24);
testRight(editor.firstChild, 27);
testRight(editor.firstChild, 38);
testLeft(editor.firstChild, 27);
testLeft(editor.firstChild, 24);
testLeft(editor.firstChild, 19);
testLeft(editor.firstChild, 12);
testLeft(editor.firstChild, 7);
testLeft(editor.firstChild, 0);
@ -334,15 +328,9 @@ function test2() {
editor.innerHTML = "layout.word_select.stop_at_punctuation";
sel.collapse(editor.firstChild, 0);
testRight(editor.firstChild, 7);
testRight(editor.firstChild, 12);
testRight(editor.firstChild, 19);
testRight(editor.firstChild, 24);
testRight(editor.firstChild, 27);
testRight(editor.firstChild, 38);
testLeft(editor.firstChild, 27);
testLeft(editor.firstChild, 24);
testLeft(editor.firstChild, 19);
testLeft(editor.firstChild, 12);
testLeft(editor.firstChild, 7);
testLeft(editor.firstChild, 0);