Commit 20f41a0e authored by danhn@chromium.org's avatar danhn@chromium.org

Fixed bidi RTL check failures on font settings page.


BUG=118420
TEST=browser_tests --gtest_filter=*.TestSettingsFrameFonts


Review URL: http://codereview.chromium.org/9838055

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133983 0039d316-1c4b-4281-b951-d872f2087c98
parent da1b58bd
...@@ -170,9 +170,12 @@ cr.define('options', function() { ...@@ -170,9 +170,12 @@ cr.define('options', function() {
for (var i = 0; i < items.length; i++) { for (var i = 0; i < items.length; i++) {
value = items[i][0]; value = items[i][0];
text = items[i][1]; text = items[i][1];
dir = items[i][2];
if (text) { if (text) {
selected = value == selectedValue; selected = value == selectedValue;
element.appendChild(new Option(text, value, false, selected)); var option = new Option(text, value, false, selected);
option.dir = dir;
element.appendChild(option);
} else { } else {
element.appendChild(document.createElement('hr')); element.appendChild(document.createElement('hr'));
} }
......
...@@ -673,9 +673,8 @@ IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestLTR, ...@@ -673,9 +673,8 @@ IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestLTR,
RunBidiCheckerOnPage(url); RunBidiCheckerOnPage(url);
} }
// http://crbug.com/118420
IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestRTL, IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTestRTL,
DISABLED_TestSettingsFrameFonts) { TestSettingsFrameFonts) {
std::string url(chrome::kChromeUISettingsFrameURL); std::string url(chrome::kChromeUISettingsFrameURL);
url += "fonts"; url += "fonts";
RunBidiCheckerOnPage(url); RunBidiCheckerOnPage(url);
......
...@@ -133,6 +133,18 @@ void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) { ...@@ -133,6 +133,18 @@ void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) {
void FontSettingsHandler::FontsListHasLoaded( void FontSettingsHandler::FontsListHasLoaded(
scoped_ptr<base::ListValue> list) { scoped_ptr<base::ListValue> list) {
// Selects the directionality for the fonts in the given list.
for (size_t i = 0; i < list->GetSize(); i++) {
ListValue* font;
bool has_font = list->GetList(i, &font);
DCHECK(has_font);
string16 value;
bool has_value = font->GetString(1, &value);
DCHECK(has_value);
bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(value);
font->Append(Value::CreateStringValue(has_rtl_chars ? "rtl" : "ltr"));
}
ListValue encoding_list; ListValue encoding_list;
const std::vector<CharacterEncoding::EncodingInfo>* encodings; const std::vector<CharacterEncoding::EncodingInfo>* encodings;
PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
...@@ -151,9 +163,10 @@ void FontSettingsHandler::FontsListHasLoaded( ...@@ -151,9 +163,10 @@ void FontSettingsHandler::FontsListHasLoaded(
std::string encoding = std::string encoding =
CharacterEncoding::GetCanonicalEncodingNameByCommandId(cmd_id); CharacterEncoding::GetCanonicalEncodingNameByCommandId(cmd_id);
string16 name = it->encoding_display_name; string16 name = it->encoding_display_name;
base::i18n::AdjustStringForLocaleDirection(&name); bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(name);
option->Append(Value::CreateStringValue(encoding)); option->Append(Value::CreateStringValue(encoding));
option->Append(Value::CreateStringValue(name)); option->Append(Value::CreateStringValue(name));
option->Append(Value::CreateStringValue(has_rtl_chars ? "rtl" : "ltr"));
} else { } else {
// Add empty name/value to indicate a separator item. // Add empty name/value to indicate a separator item.
option->Append(Value::CreateStringValue("")); option->Append(Value::CreateStringValue(""));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment