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

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

Issue 2348143003: MacViews: Implement Force Touch/Mac dictionary lookup for Textfields. (Closed)
Patch Set: Fix compile. Created 4 years, 2 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 gfx::Size Textfield::GetPreferredSize() const { 550 gfx::Size Textfield::GetPreferredSize() const {
551 const gfx::Insets& insets = GetInsets(); 551 const gfx::Insets& insets = GetInsets();
552 return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) + 552 return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) +
553 insets.width(), GetFontList().GetHeight() + insets.height()); 553 insets.width(), GetFontList().GetHeight() + insets.height());
554 } 554 }
555 555
556 const char* Textfield::GetClassName() const { 556 const char* Textfield::GetClassName() const {
557 return kViewClassName; 557 return kViewClassName;
558 } 558 }
559 559
560 gfx::RenderText* Textfield::GetRenderText() const {
561 return model_->render_text();
562 }
563
560 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { 564 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) {
561 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); 565 bool in_selection = GetRenderText()->IsPointInSelection(event.location());
562 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; 566 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED;
563 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); 567 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection);
564 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor; 568 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor;
565 } 569 }
566 570
567 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { 571 bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
568 TrackMouseClicks(event); 572 TrackMouseClicks(event);
569 573
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 void Textfield::DoInsertChar(base::char16 ch) { 1555 void Textfield::DoInsertChar(base::char16 ch) {
1552 OnBeforeUserAction(); 1556 OnBeforeUserAction();
1553 skip_input_method_cancel_composition_ = true; 1557 skip_input_method_cancel_composition_ = true;
1554 model_->InsertChar(ch); 1558 model_->InsertChar(ch);
1555 skip_input_method_cancel_composition_ = false; 1559 skip_input_method_cancel_composition_ = false;
1556 1560
1557 UpdateAfterChange(true, true); 1561 UpdateAfterChange(true, true);
1558 OnAfterUserAction(); 1562 OnAfterUserAction();
1559 } 1563 }
1560 1564
1561 gfx::RenderText* Textfield::GetRenderText() const {
1562 return model_->render_text();
1563 }
1564
1565 base::string16 Textfield::GetSelectionClipboardText() const { 1565 base::string16 Textfield::GetSelectionClipboardText() const {
1566 base::string16 selection_clipboard_text; 1566 base::string16 selection_clipboard_text;
1567 ui::Clipboard::GetForCurrentThread()->ReadText( 1567 ui::Clipboard::GetForCurrentThread()->ReadText(
1568 ui::CLIPBOARD_TYPE_SELECTION, &selection_clipboard_text); 1568 ui::CLIPBOARD_TYPE_SELECTION, &selection_clipboard_text);
1569 return selection_clipboard_text; 1569 return selection_clipboard_text;
1570 } 1570 }
1571 1571
1572 void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) { 1572 void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) {
1573 DestroyTouchSelection(); 1573 DestroyTouchSelection();
1574 1574
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 } 2059 }
2060 2060
2061 void Textfield::OnCursorBlinkTimerFired() { 2061 void Textfield::OnCursorBlinkTimerFired() {
2062 DCHECK(ShouldBlinkCursor()); 2062 DCHECK(ShouldBlinkCursor());
2063 gfx::RenderText* render_text = GetRenderText(); 2063 gfx::RenderText* render_text = GetRenderText();
2064 render_text->set_cursor_visible(!render_text->cursor_visible()); 2064 render_text->set_cursor_visible(!render_text->cursor_visible());
2065 RepaintCursor(); 2065 RepaintCursor();
2066 } 2066 }
2067 2067
2068 } // namespace views 2068 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698