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

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

Issue 358553004: Added text filtering to Overview Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 use_default_selection_background_color_(true), 261 use_default_selection_background_color_(true),
262 text_color_(SK_ColorBLACK), 262 text_color_(SK_ColorBLACK),
263 background_color_(SK_ColorWHITE), 263 background_color_(SK_ColorWHITE),
264 selection_text_color_(SK_ColorWHITE), 264 selection_text_color_(SK_ColorWHITE),
265 selection_background_color_(SK_ColorBLUE), 265 selection_background_color_(SK_ColorBLUE),
266 placeholder_text_color_(kDefaultPlaceholderTextColor), 266 placeholder_text_color_(kDefaultPlaceholderTextColor),
267 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), 267 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
268 performing_user_action_(false), 268 performing_user_action_(false),
269 skip_input_method_cancel_composition_(false), 269 skip_input_method_cancel_composition_(false),
270 cursor_visible_(false), 270 cursor_visible_(false),
271 has_shadow_(false),
271 drop_cursor_visible_(false), 272 drop_cursor_visible_(false),
272 initiating_drag_(false), 273 initiating_drag_(false),
273 aggregated_clicks_(0), 274 aggregated_clicks_(0),
274 weak_ptr_factory_(this) { 275 weak_ptr_factory_(this) {
275 set_context_menu_controller(this); 276 set_context_menu_controller(this);
276 set_drag_controller(this); 277 set_drag_controller(this);
277 SetBorder(scoped_ptr<Border>(new FocusableBorder())); 278 SetBorder(scoped_ptr<Border>(new FocusableBorder()));
278 SetFocusable(true); 279 SetFocusable(true);
279 280
280 if (ViewsDelegate::views_delegate) { 281 if (ViewsDelegate::views_delegate) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 SchedulePaint(); 425 SchedulePaint();
425 } 426 }
426 427
427 void Textfield::UseDefaultSelectionBackgroundColor() { 428 void Textfield::UseDefaultSelectionBackgroundColor() {
428 use_default_selection_background_color_ = true; 429 use_default_selection_background_color_ = true;
429 GetRenderText()->set_selection_background_focused_color( 430 GetRenderText()->set_selection_background_focused_color(
430 GetSelectionBackgroundColor()); 431 GetSelectionBackgroundColor());
431 SchedulePaint(); 432 SchedulePaint();
432 } 433 }
433 434
435 void Textfield::DisplayShadow(bool display_shadow) {
436 has_shadow_ = display_shadow;
437 SchedulePaint();
tdanderson 2014/06/25 15:48:23 It should be the responsibility of the caller to i
Nina 2014/06/26 15:20:18 Hmmm all the other setters call SchedulePaint(). I
438 }
439
434 bool Textfield::GetCursorEnabled() const { 440 bool Textfield::GetCursorEnabled() const {
435 return GetRenderText()->cursor_enabled(); 441 return GetRenderText()->cursor_enabled();
436 } 442 }
437 443
438 void Textfield::SetCursorEnabled(bool enabled) { 444 void Textfield::SetCursorEnabled(bool enabled) {
439 GetRenderText()->SetCursorEnabled(enabled); 445 GetRenderText()->SetCursorEnabled(enabled);
440 } 446 }
441 447
442 const gfx::FontList& Textfield::GetFontList() const { 448 const gfx::FontList& Textfield::GetFontList() const {
443 return GetRenderText()->font_list(); 449 return GetRenderText()->font_list();
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 // Draw placeholder text if needed. 1587 // Draw placeholder text if needed.
1582 gfx::RenderText* render_text = GetRenderText(); 1588 gfx::RenderText* render_text = GetRenderText();
1583 if (text().empty() && !GetPlaceholderText().empty()) { 1589 if (text().empty() && !GetPlaceholderText().empty()) {
1584 canvas->DrawStringRect(GetPlaceholderText(), GetFontList(), 1590 canvas->DrawStringRect(GetPlaceholderText(), GetFontList(),
1585 placeholder_text_color(), render_text->display_rect()); 1591 placeholder_text_color(), render_text->display_rect());
1586 } 1592 }
1587 1593
1588 // Draw the text, cursor, and selection. 1594 // Draw the text, cursor, and selection.
1589 render_text->set_cursor_visible(cursor_visible_ && !drop_cursor_visible_ && 1595 render_text->set_cursor_visible(cursor_visible_ && !drop_cursor_visible_ &&
1590 !HasSelection()); 1596 !HasSelection());
1597
1598 if (has_shadow_) {
1599 // Draw a basic shadow underneath the text.
1600 gfx::ShadowValues shadows;
1601 shadows.push_back(gfx::ShadowValue(gfx::Point(0, 1), 10, SK_ColorBLACK));
tdanderson 2014/06/25 15:48:23 I wonder if it's worthwhile defining constants for
Nina 2014/06/26 15:20:18 As we discussed off the patch, we might want to ch
1602 render_text->set_shadows(shadows);
1603 }
1604
1591 render_text->Draw(canvas); 1605 render_text->Draw(canvas);
1592 1606
1593 // Draw the detached drop cursor that marks where the text will be dropped. 1607 // Draw the detached drop cursor that marks where the text will be dropped.
1594 if (drop_cursor_visible_) 1608 if (drop_cursor_visible_)
1595 render_text->DrawCursor(canvas, drop_cursor_position_); 1609 render_text->DrawCursor(canvas, drop_cursor_position_);
1596 1610
1597 canvas->Restore(); 1611 canvas->Restore();
1598 } 1612 }
1599 1613
1600 void Textfield::MoveCursorTo(const gfx::Point& point, bool select) { 1614 void Textfield::MoveCursorTo(const gfx::Point& point, bool select) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 const size_t length = selection_clipboard_text.length(); 1775 const size_t length = selection_clipboard_text.length();
1762 range = gfx::Range(range.start() + length, range.end() + length); 1776 range = gfx::Range(range.start() + length, range.end() + length);
1763 } 1777 }
1764 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); 1778 model_->MoveCursorTo(gfx::SelectionModel(range, affinity));
1765 UpdateAfterChange(true, true); 1779 UpdateAfterChange(true, true);
1766 OnAfterUserAction(); 1780 OnAfterUserAction();
1767 } 1781 }
1768 } 1782 }
1769 1783
1770 } // namespace views 1784 } // namespace views
OLDNEW
« ui/views/controls/textfield/textfield.h ('K') | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698