Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 1031533002: Supports the invisible underline for native input fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revised per comments. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/views/controls/textfield/textfield_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 gfx::Rect rect = GetRenderText()->GetUpdatedCursorBounds(); 1483 gfx::Rect rect = GetRenderText()->GetUpdatedCursorBounds();
1484 ConvertRectToScreen(this, &rect); 1484 ConvertRectToScreen(this, &rect);
1485 return rect; 1485 return rect;
1486 } 1486 }
1487 1487
1488 bool Textfield::GetCompositionCharacterBounds(uint32 index, 1488 bool Textfield::GetCompositionCharacterBounds(uint32 index,
1489 gfx::Rect* rect) const { 1489 gfx::Rect* rect) const {
1490 DCHECK(rect); 1490 DCHECK(rect);
1491 if (!HasCompositionText()) 1491 if (!HasCompositionText())
1492 return false; 1492 return false;
1493 gfx::RenderText* render_text = GetRenderText(); 1493 gfx::Range composition_range;
1494 const gfx::Range& composition_range = render_text->GetCompositionRange(); 1494 model_->GetCompositionTextRange(&composition_range);
1495 DCHECK(!composition_range.is_empty()); 1495 DCHECK(!composition_range.is_empty());
1496 1496
1497 size_t text_index = composition_range.start() + index; 1497 size_t text_index = composition_range.start() + index;
1498 if (composition_range.end() <= text_index) 1498 if (composition_range.end() <= text_index)
1499 return false; 1499 return false;
1500 gfx::RenderText* render_text = GetRenderText();
1500 if (!render_text->IsValidCursorIndex(text_index)) { 1501 if (!render_text->IsValidCursorIndex(text_index)) {
1501 text_index = render_text->IndexOfAdjacentGrapheme( 1502 text_index = render_text->IndexOfAdjacentGrapheme(
1502 text_index, gfx::CURSOR_BACKWARD); 1503 text_index, gfx::CURSOR_BACKWARD);
1503 } 1504 }
1504 if (text_index < composition_range.start()) 1505 if (text_index < composition_range.start())
1505 return false; 1506 return false;
1506 const gfx::SelectionModel caret(text_index, gfx::CURSOR_BACKWARD); 1507 const gfx::SelectionModel caret(text_index, gfx::CURSOR_BACKWARD);
1507 *rect = render_text->GetCursorBounds(caret, false); 1508 *rect = render_text->GetCursorBounds(caret, false);
1508 ConvertRectToScreen(this, rect); 1509 ConvertRectToScreen(this, rect);
1509 return true; 1510 return true;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 RequestFocus(); 1886 RequestFocus();
1886 model_->MoveCursorTo(mouse); 1887 model_->MoveCursorTo(mouse);
1887 if (!selection_clipboard_text.empty()) { 1888 if (!selection_clipboard_text.empty()) {
1888 model_->InsertText(selection_clipboard_text); 1889 model_->InsertText(selection_clipboard_text);
1889 UpdateAfterChange(true, true); 1890 UpdateAfterChange(true, true);
1890 } 1891 }
1891 OnAfterUserAction(); 1892 OnAfterUserAction();
1892 } 1893 }
1893 1894
1894 } // namespace views 1895 } // namespace views
OLDNEW
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/views/controls/textfield/textfield_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698