Bug 1066756 - Include characters with Unicode category Sk (modifier symbol) in double-click word selection. r=mats

This commit is contained in:
Jonathan Kew 2014-09-15 17:19:24 +01:00
Родитель 63feeb0f58
Коммит 7b32611a01
3 изменённых файлов: 54 добавлений и 6 удалений

Просмотреть файл

@ -90,7 +90,7 @@ of values.
nsIUGenCategory::nsUGenCategory sDetailedToGeneralCategory[] = {
/*
* The order here corresponds to the HB_UNICODE_GENERAL_CATEGORY_* constants
* of the hb_unicode_general_category_t enum in gfx/harfbuzz/src/hb-common.h.
* of the hb_unicode_general_category_t enum in gfx/harfbuzz/src/hb-unicode.h.
*/
/* CONTROL */ nsIUGenCategory::kOther,
/* FORMAT */ nsIUGenCategory::kOther,

Просмотреть файл

@ -6726,9 +6726,27 @@ bool
ClusterIterator::IsPunctuation()
{
NS_ASSERTION(mCharIndex >= 0, "No cluster selected");
nsIUGenCategory::nsUGenCategory c =
mozilla::unicode::GetGenCategory(mFrag->CharAt(mCharIndex));
return c == nsIUGenCategory::kPunctuation || c == nsIUGenCategory::kSymbol;
// 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));
switch (cat) {
case HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION: /* Pc */
case HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION: /* Pd */
case HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION: /* Pe */
case HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION: /* Pf */
case HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION: /* Pi */
case HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION: /* Po */
case HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION: /* Ps */
case HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL: /* Sc */
// Deliberately omitted:
// case HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL: /* Sk */
case HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL: /* Sm */
case HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL: /* So */
return true;
default:
return false;
}
}
int32_t

Просмотреть файл

@ -14,7 +14,7 @@
<p id="catch">Catch-all
<pre id="test"><script class="testbody" type="text/javascript;version=1.7">
/** Tests for bugs 384147 and 981281 **/
/** Tests for bugs 384147, 981281, 1066756 **/
SimpleTest.waitForExplicitFinish();
@ -63,7 +63,8 @@ var ChineseChars = "&#x6F22;&#x5B57;";
var HiraganaChars = "&#x3072;&#x3089;&#x304C;&#x306A;";
var KatakanaChars = "&#x30AB;&#x30BF;&#x30AB;&#x30CA;";
var JapaneseFullStop = "&#x3002;";
var JapaneseComma = "&#x3001";
var JapaneseComma = "&#x3001;";
var ModifierColon = "&#xA789;";
function test() {
setPrefs(false, true, test1);
@ -176,6 +177,14 @@ function test1() {
testLeft(editor.firstChild, 3);
testLeft(editor.firstChild, 0);
// test for bug 1066756
editor.innerHTML = "hello" + ModifierColon + " wo" + ModifierColon + "rld";
sel.collapse(editor.firstChild, 0);
testRight(editor.firstChild, 6);
testRight(editor.firstChild, 13);
testLeft(editor.firstChild, 7);
testLeft(editor.firstChild, 0);
// test basic word movement with eat_space_next_to_word true.
setPrefs(true, true, test2);
}
@ -285,6 +294,13 @@ function test2() {
testLeft(editor.firstChild, 3);
testLeft(editor.firstChild, 0);
editor.innerHTML = "hello" + ModifierColon + " wo" + ModifierColon + "rld";
sel.collapse(editor.firstChild, 0);
testRight(editor.firstChild, 7);
testRight(editor.firstChild, 13);
testLeft(editor.firstChild, 7);
testLeft(editor.firstChild, 0);
// Test basic word movement with stop_at_punctuation false (bug 981281).
setPrefs(false, false, test3);
}
@ -378,6 +394,13 @@ function test3() {
testRight(editor.firstChild, 8);
testLeft(editor.firstChild, 0);
editor.innerHTML = "hello" + ModifierColon + " wo" + ModifierColon + "rld";
sel.collapse(editor.firstChild, 0);
testRight(editor.firstChild, 6);
testRight(editor.firstChild, 13);
testLeft(editor.firstChild, 7);
testLeft(editor.firstChild, 0);
// And again with eat_space_next_to_word true.
setPrefs(true, false, test4);
}
@ -471,6 +494,13 @@ function test4() {
testRight(editor.firstChild, 8);
testLeft(editor.firstChild, 0);
editor.innerHTML = "hello" + ModifierColon + " wo" + ModifierColon + "rld";
sel.collapse(editor.firstChild, 0);
testRight(editor.firstChild, 7);
testRight(editor.firstChild, 13);
testLeft(editor.firstChild, 7);
testLeft(editor.firstChild, 0);
SimpleTest.finish();
}