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

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, 3 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 gfx::Size Textfield::GetPreferredSize() const { 551 gfx::Size Textfield::GetPreferredSize() const {
552 const gfx::Insets& insets = GetInsets(); 552 const gfx::Insets& insets = GetInsets();
553 return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) + 553 return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) +
554 insets.width(), GetFontList().GetHeight() + insets.height()); 554 insets.width(), GetFontList().GetHeight() + insets.height());
555 } 555 }
556 556
557 const char* Textfield::GetClassName() const { 557 const char* Textfield::GetClassName() const {
558 return kViewClassName; 558 return kViewClassName;
559 } 559 }
560 560
561 gfx::RenderText* Textfield::GetRenderText() const {
562 return model_->render_text();
563 }
564
561 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) { 565 gfx::NativeCursor Textfield::GetCursor(const ui::MouseEvent& event) {
562 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); 566 bool in_selection = GetRenderText()->IsPointInSelection(event.location());
563 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED; 567 bool drag_event = event.type() == ui::ET_MOUSE_DRAGGED;
564 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection); 568 bool text_cursor = !initiating_drag_ && (drag_event || !in_selection);
565 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor; 569 return text_cursor ? GetNativeIBeamCursor() : gfx::kNullCursor;
566 } 570 }
567 571
568 bool Textfield::OnMousePressed(const ui::MouseEvent& event) { 572 bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
569 TrackMouseClicks(event); 573 TrackMouseClicks(event);
570 574
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 void Textfield::DoInsertChar(base::char16 ch) { 1548 void Textfield::DoInsertChar(base::char16 ch) {
1545 OnBeforeUserAction(); 1549 OnBeforeUserAction();
1546 skip_input_method_cancel_composition_ = true; 1550 skip_input_method_cancel_composition_ = true;
1547 model_->InsertChar(ch); 1551 model_->InsertChar(ch);
1548 skip_input_method_cancel_composition_ = false; 1552 skip_input_method_cancel_composition_ = false;
1549 1553
1550 UpdateAfterChange(true, true); 1554 UpdateAfterChange(true, true);
1551 OnAfterUserAction(); 1555 OnAfterUserAction();
1552 } 1556 }
1553 1557
1554 gfx::RenderText* Textfield::GetRenderText() const {
1555 return model_->render_text();
1556 }
1557
1558 base::string16 Textfield::GetSelectionClipboardText() const { 1558 base::string16 Textfield::GetSelectionClipboardText() const {
1559 base::string16 selection_clipboard_text; 1559 base::string16 selection_clipboard_text;
1560 ui::Clipboard::GetForCurrentThread()->ReadText( 1560 ui::Clipboard::GetForCurrentThread()->ReadText(
1561 ui::CLIPBOARD_TYPE_SELECTION, &selection_clipboard_text); 1561 ui::CLIPBOARD_TYPE_SELECTION, &selection_clipboard_text);
1562 return selection_clipboard_text; 1562 return selection_clipboard_text;
1563 } 1563 }
1564 1564
1565 void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) { 1565 void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) {
1566 DestroyTouchSelection(); 1566 DestroyTouchSelection();
1567 1567
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 RequestFocus(); 2027 RequestFocus();
2028 model_->MoveCursorTo(mouse); 2028 model_->MoveCursorTo(mouse);
2029 if (!selection_clipboard_text.empty()) { 2029 if (!selection_clipboard_text.empty()) {
2030 model_->InsertText(selection_clipboard_text); 2030 model_->InsertText(selection_clipboard_text);
2031 UpdateAfterChange(true, true); 2031 UpdateAfterChange(true, true);
2032 } 2032 }
2033 OnAfterUserAction(); 2033 OnAfterUserAction();
2034 } 2034 }
2035 2035
2036 } // namespace views 2036 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698