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

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 and fixed test failures. Created 5 years, 9 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
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 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 gfx::Rect rect = GetRenderText()->GetUpdatedCursorBounds(); 1478 gfx::Rect rect = GetRenderText()->GetUpdatedCursorBounds();
1479 ConvertRectToScreen(this, &rect); 1479 ConvertRectToScreen(this, &rect);
1480 return rect; 1480 return rect;
1481 } 1481 }
1482 1482
1483 bool Textfield::GetCompositionCharacterBounds(uint32 index, 1483 bool Textfield::GetCompositionCharacterBounds(uint32 index,
1484 gfx::Rect* rect) const { 1484 gfx::Rect* rect) const {
1485 DCHECK(rect); 1485 DCHECK(rect);
1486 if (!HasCompositionText()) 1486 if (!HasCompositionText())
1487 return false; 1487 return false;
1488 gfx::RenderText* render_text = GetRenderText(); 1488 gfx::Range composition_range;
1489 const gfx::Range& composition_range = render_text->GetCompositionRange(); 1489 model_->GetCompositionTextRange(&composition_range);
1490 DCHECK(!composition_range.is_empty()); 1490 DCHECK(!composition_range.is_empty());
1491 1491
1492 size_t text_index = composition_range.start() + index; 1492 size_t text_index = composition_range.start() + index;
1493 if (composition_range.end() <= text_index) 1493 if (composition_range.end() <= text_index)
1494 return false; 1494 return false;
1495 gfx::RenderText* render_text = GetRenderText();
1495 if (!render_text->IsValidCursorIndex(text_index)) { 1496 if (!render_text->IsValidCursorIndex(text_index)) {
1496 text_index = render_text->IndexOfAdjacentGrapheme( 1497 text_index = render_text->IndexOfAdjacentGrapheme(
1497 text_index, gfx::CURSOR_BACKWARD); 1498 text_index, gfx::CURSOR_BACKWARD);
1498 } 1499 }
1499 if (text_index < composition_range.start()) 1500 if (text_index < composition_range.start())
1500 return false; 1501 return false;
1501 const gfx::SelectionModel caret(text_index, gfx::CURSOR_BACKWARD); 1502 const gfx::SelectionModel caret(text_index, gfx::CURSOR_BACKWARD);
1502 *rect = render_text->GetCursorBounds(caret, false); 1503 *rect = render_text->GetCursorBounds(caret, false);
1503 ConvertRectToScreen(this, rect); 1504 ConvertRectToScreen(this, rect);
1504 return true; 1505 return true;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 RequestFocus(); 1881 RequestFocus();
1881 model_->MoveCursorTo(mouse); 1882 model_->MoveCursorTo(mouse);
1882 if (!selection_clipboard_text.empty()) { 1883 if (!selection_clipboard_text.empty()) {
1883 model_->InsertText(selection_clipboard_text); 1884 model_->InsertText(selection_clipboard_text);
1884 UpdateAfterChange(true, true); 1885 UpdateAfterChange(true, true);
1885 } 1886 }
1886 OnAfterUserAction(); 1887 OnAfterUserAction();
1887 } 1888 }
1888 1889
1889 } // namespace views 1890 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698