diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-02 17:08:17 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-02 17:08:17 +0000 |
commit | 3dbc8a684c201efb75f7c18ebe07de4e560c862e (patch) | |
tree | b932658f33dce5b817f754274330745f596440e1 /ui/gfx/render_text_mac.cc | |
parent | 595fe3fa08135ab7cb711cffc498b3c563a5368a (diff) | |
download | chromium_src-3dbc8a684c201efb75f7c18ebe07de4e560c862e.zip chromium_src-3dbc8a684c201efb75f7c18ebe07de4e560c862e.tar.gz chromium_src-3dbc8a684c201efb75f7c18ebe07de4e560c862e.tar.bz2 |
Reland: Fix Views inline autocomplete with multi-char graphemes.
(originally r267752, reverted in r267765 for XP test failures)
(test disabled on XP for a lack of font support, issue 106450)
Allow RenderText selection bounds amid multi-char graphemes.
Add a consolidated IsValidLogicalIndex implementation.
(this is less strict than the renamed IsValidCursorIndex)
Use adjacent cursor positions in MoveCursor as needed.
(prevents invalid cursors when collapsing selections)
Skip painting empty glyph ranges on Windows.
Add a unit test; minor cleanup and comment changes.
BUG=327903,366786,106450
TEST=Search for "จำลอง" in the omnibox; enter "จ" and get a valid selection of the inline autocomplete text.
TBR=asvitkine@chromium.org
Review URL: https://codereview.chromium.org/265903004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267826 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/render_text_mac.cc')
-rw-r--r-- | ui/gfx/render_text_mac.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ui/gfx/render_text_mac.cc b/ui/gfx/render_text_mac.cc index af0be63..3ad484b 100644 --- a/ui/gfx/render_text_mac.cc +++ b/ui/gfx/render_text_mac.cc @@ -45,7 +45,7 @@ std::vector<RenderText::FontSpan> RenderTextMac::GetFontSpansForTesting() { std::vector<RenderText::FontSpan> spans; for (size_t i = 0; i < runs_.size(); ++i) { - gfx::Font font(runs_[i].font_name, runs_[i].text_size); + Font font(runs_[i].font_name, runs_[i].text_size); const CFRange cf_range = CTRunGetStringRange(runs_[i].ct_run); const Range range(cf_range.location, cf_range.location + cf_range.length); spans.push_back(RenderText::FontSpan(font, range)); @@ -93,9 +93,9 @@ size_t RenderTextMac::LayoutIndexToTextIndex(size_t index) const { return index; } -bool RenderTextMac::IsCursorablePosition(size_t position) { +bool RenderTextMac::IsValidCursorIndex(size_t index) { // TODO(asvitkine): Implement this. http://crbug.com/131618 - return true; + return IsValidLogicalIndex(index); } void RenderTextMac::ResetLayout() { @@ -211,7 +211,7 @@ void RenderTextMac::ApplyStyles(CFMutableAttributedStringRef attr_string, end = TextIndexToLayoutIndex(style.GetRange().end()); const CFRange range = CFRangeMake(i, end - i); base::ScopedCFTypeRef<CGColorRef> foreground( - gfx::CGColorCreateFromSkColor(style.color())); + CGColorCreateFromSkColor(style.color())); CFAttributedStringSetAttribute(attr_string, range, kCTForegroundColorAttributeName, foreground); CFArrayAppendValue(attributes_, foreground); @@ -254,9 +254,9 @@ void RenderTextMac::ComputeRuns() { // TODO(asvitkine): Don't use GetLineOffset() until draw time, since it may be // updated based on alignment changes without resetting the layout. - gfx::Vector2d text_offset = GetLineOffset(0); + Vector2d text_offset = GetLineOffset(0); // Skia will draw glyphs with respect to the baseline. - text_offset += gfx::Vector2d(0, common_baseline_); + text_offset += Vector2d(0, common_baseline_); const SkScalar x = SkIntToScalar(text_offset.x()); const SkScalar y = SkIntToScalar(text_offset.y()); @@ -325,7 +325,7 @@ void RenderTextMac::ComputeRuns() { base::mac::GetValueFromDictionary<CGColorRef>( attributes, kCTForegroundColorAttributeName); if (foreground) - run->foreground = gfx::CGColorRefToSkColor(foreground); + run->foreground = CGColorRefToSkColor(foreground); const CFNumberRef underline = base::mac::GetValueFromDictionary<CFNumberRef>( |