diff options
author | ckocagil@chromium.org <ckocagil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-09 18:04:12 +0000 |
---|---|---|
committer | ckocagil@chromium.org <ckocagil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-09 18:05:40 +0000 |
commit | 925fea1e3bece4b2e8909c5731cc4874a8cab80d (patch) | |
tree | 0d5947d546673a33496750dd2508434f0a396055 /ui | |
parent | 3e5701b4c8e127bd57bb862150a3e9a0c7f1502c (diff) | |
download | chromium_src-925fea1e3bece4b2e8909c5731cc4874a8cab80d.zip chromium_src-925fea1e3bece4b2e8909c5731cc4874a8cab80d.tar.gz chromium_src-925fea1e3bece4b2e8909c5731cc4874a8cab80d.tar.bz2 |
Enable RenderTextHarfBuzz by default
BUG=321868
TBR=msw
Review URL: https://codereview.chromium.org/421053002
Cr-Commit-Position: refs/heads/master@{#288588}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/render_text.cc | 4 | ||||
-rw-r--r-- | ui/gfx/render_text.h | 1 | ||||
-rw-r--r-- | ui/gfx/render_text_harfbuzz.cc | 18 | ||||
-rw-r--r-- | ui/gfx/render_text_unittest.cc | 2 |
4 files changed, 20 insertions, 5 deletions
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index e7144f8..807f8cd 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -426,8 +426,8 @@ RenderText* RenderText::CreateInstance() { // Use the more complete HarfBuzz implementation for Views controls on Mac. return new RenderTextHarfBuzz; #else - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableHarfBuzzRenderText)) { + if (!CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableHarfBuzzRenderText)) { return new RenderTextHarfBuzz; } return CreateNativeInstance(); diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h index e5a17a1..80055b0 100644 --- a/ui/gfx/render_text.h +++ b/ui/gfx/render_text.h @@ -579,6 +579,7 @@ class GFX_EXPORT RenderText { FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters); FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses); FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks); + FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); // Creates a platform-specific RenderText instance. static RenderText* CreateNativeInstance(); diff --git a/ui/gfx/render_text_harfbuzz.cc b/ui/gfx/render_text_harfbuzz.cc index c808376..3df3298 100644 --- a/ui/gfx/render_text_harfbuzz.cc +++ b/ui/gfx/render_text_harfbuzz.cc @@ -658,8 +658,6 @@ SelectionModel RenderTextHarfBuzz::AdjacentCharSelectionModel( SelectionModel RenderTextHarfBuzz::AdjacentWordSelectionModel( const SelectionModel& selection, VisualCursorDirection direction) { - // TODO(ckocagil): This implementation currently matches RenderTextWin, but it - // should match the native behavior on other platforms. if (obscured()) return EdgeSelectionModel(direction); @@ -669,6 +667,8 @@ SelectionModel RenderTextHarfBuzz::AdjacentWordSelectionModel( if (!success) return selection; + // Match OS specific word break behavior. +#if defined(OS_WIN) size_t pos; if (direction == CURSOR_RIGHT) { pos = std::min(selection.caret_pos() + 1, text().length()); @@ -701,6 +701,20 @@ SelectionModel RenderTextHarfBuzz::AdjacentWordSelectionModel( } } return SelectionModel(pos, CURSOR_FORWARD); +#else + SelectionModel cur(selection); + for (;;) { + cur = AdjacentCharSelectionModel(cur, direction); + size_t run = GetRunContainingCaret(cur); + if (run == runs_.size()) + break; + const bool is_forward = runs_[run]->is_rtl == (direction == CURSOR_LEFT); + size_t cursor = cur.caret_pos(); + if (is_forward ? iter.IsEndOfWord(cursor) : iter.IsStartOfWord(cursor)) + break; + } + return cur; +#endif } std::vector<Rect> RenderTextHarfBuzz::GetSubstringBounds(const Range& range) { diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc index 108beb3..5140d9e 100644 --- a/ui/gfx/render_text_unittest.cc +++ b/ui/gfx/render_text_unittest.cc @@ -186,7 +186,7 @@ TEST_F(RenderTextTest, ApplyColorAndStyle) { #if defined(OS_LINUX) && !defined(USE_OZONE) TEST_F(RenderTextTest, PangoAttributes) { - scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); + scoped_ptr<RenderText> render_text(RenderText::CreateNativeInstance()); render_text->SetText(ASCIIToUTF16("012345678")); // Apply ranged BOLD/ITALIC styles and check the resulting Pango attributes. |