OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/common/l10n_util.h" | 7 #include "chrome/common/l10n_util.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 void WrapStringWithRTLFormatting(std::wstring* text) { | 553 void WrapStringWithRTLFormatting(std::wstring* text) { |
554 // Inserting an RLE (Right-To-Left Embedding) mark as the first character. | 554 // Inserting an RLE (Right-To-Left Embedding) mark as the first character. |
555 text->insert(0, 1, static_cast<wchar_t>(kRightToLeftEmbeddingMark)); | 555 text->insert(0, 1, static_cast<wchar_t>(kRightToLeftEmbeddingMark)); |
556 | 556 |
557 // Inserting a PDF (Pop Directional Formatting) mark as the last character. | 557 // Inserting a PDF (Pop Directional Formatting) mark as the last character. |
558 text->push_back(static_cast<wchar_t>(kPopDirectionalFormatting)); | 558 text->push_back(static_cast<wchar_t>(kPopDirectionalFormatting)); |
559 } | 559 } |
560 | 560 |
561 void WrapPathWithLTRFormatting(const FilePath& path, | 561 void WrapPathWithLTRFormatting(const FilePath& path, |
562 string16* rtl_safe_path) { | 562 string16* rtl_safe_path) { |
563 // Split the path. | 563 // Wrap the overall path with LRE-PDF pair which essentialy marks the |
564 std::vector<FilePath::StringType> path_components; | 564 // string as a Left-To-Right string. |
565 file_util::PathComponents(path, &path_components); | |
566 // Compose the whole path from components with the following 2 additions: | |
567 // 1. Wrap the overall path with LRE-PDF pair which essentialy marks the | |
568 // string as a Left-To-Right string. Otherwise, the punctuation (if there is | |
569 // any) at the end of the path will not be displayed at the correct position. | |
570 // Inserting an LRE (Left-To-Right Embedding) mark as the first character. | 565 // Inserting an LRE (Left-To-Right Embedding) mark as the first character. |
571 rtl_safe_path->push_back(kLeftToRightEmbeddingMark); | 566 rtl_safe_path->push_back(kLeftToRightEmbeddingMark); |
572 char16 path_separator = static_cast<char16>(FilePath::kSeparators[0]); | |
573 for (size_t index = 0; index < path_components.size(); ++index) { | |
574 #if defined(OS_MACOSX) | 567 #if defined(OS_MACOSX) |
575 rtl_safe_path->append(UTF8ToUTF16(path_components[index])); | 568 rtl_safe_path->append(UTF8ToUTF16(path.value())); |
576 #elif defined(OS_WIN) | 569 #elif defined(OS_WIN) |
577 rtl_safe_path->append(path_components[index]); | 570 rtl_safe_path->append(path.value()); |
578 #else // defined(OS_LINUX) | 571 #else // defined(OS_LINUX) |
579 std::wstring one_component = | 572 std::wstring wide_path = base::SysNativeMBToWide(path.value()); |
580 base::SysNativeMBToWide(path_components[index]); | 573 rtl_safe_path->append(WideToUTF16(wide_path)); |
581 rtl_safe_path->append(WideToUTF16(one_component)); | |
582 #endif | 574 #endif |
583 bool first_component_is_separator = | |
584 ((index == 0) && | |
585 (path_components[0].length() == 1) && | |
586 (FilePath::IsSeparator(path_components[0][0]))); | |
587 bool last_component = (index == path_components.size() - 1); | |
588 // Add separator for components except for the first component if itself is | |
589 // a separator, and except for the last component. | |
590 if (!last_component && !first_component_is_separator) { | |
591 rtl_safe_path->push_back(path_separator); | |
592 // 2. Add left-to-right mark after path separator to force each subfolder | |
593 // in the path to have LTR directionality. Otherwise, folder path | |
594 // "CBA/FED" (in which, "CBA" and "FED" stand for folder names in Hebrew, | |
595 // and "FED" is a subfolder of "CBA") will be displayed as "FED/CBA". | |
596 rtl_safe_path->push_back(kLeftToRightMark); | |
597 } | |
598 } | |
599 // Inserting a PDF (Pop Directional Formatting) mark as the last character. | 575 // Inserting a PDF (Pop Directional Formatting) mark as the last character. |
600 rtl_safe_path->push_back(kPopDirectionalFormatting); | 576 rtl_safe_path->push_back(kPopDirectionalFormatting); |
601 } | 577 } |
602 | 578 |
603 int DefaultCanvasTextAlignment() { | 579 int DefaultCanvasTextAlignment() { |
604 if (GetTextDirection() == LEFT_TO_RIGHT) { | 580 if (GetTextDirection() == LEFT_TO_RIGHT) { |
605 return ChromeCanvas::TEXT_ALIGN_LEFT; | 581 return ChromeCanvas::TEXT_ALIGN_LEFT; |
606 } else { | 582 } else { |
607 return ChromeCanvas::TEXT_ALIGN_RIGHT; | 583 return ChromeCanvas::TEXT_ALIGN_RIGHT; |
608 } | 584 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 } | 701 } |
726 | 702 |
727 void BiDiLineIterator::GetLogicalRun(int start, | 703 void BiDiLineIterator::GetLogicalRun(int start, |
728 int* end, | 704 int* end, |
729 UBiDiLevel* level) { | 705 UBiDiLevel* level) { |
730 DCHECK(bidi_ != NULL); | 706 DCHECK(bidi_ != NULL); |
731 ubidi_getLogicalRun(bidi_, start, end, level); | 707 ubidi_getLogicalRun(bidi_, start, end, level); |
732 } | 708 } |
733 | 709 |
734 } | 710 } |
OLD | NEW |