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

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

Issue 2348143003: MacViews: Implement Force Touch/Mac dictionary lookup for Textfields. (Closed)
Patch Set: Address review. 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 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 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 void Textfield::DoInsertChar(base::char16 ch) { 1556 void Textfield::DoInsertChar(base::char16 ch) {
1553 OnBeforeUserAction(); 1557 OnBeforeUserAction();
1554 skip_input_method_cancel_composition_ = true; 1558 skip_input_method_cancel_composition_ = true;
1555 model_->InsertChar(ch); 1559 model_->InsertChar(ch);
1556 skip_input_method_cancel_composition_ = false; 1560 skip_input_method_cancel_composition_ = false;
1557 1561
1558 UpdateAfterChange(true, true); 1562 UpdateAfterChange(true, true);
1559 OnAfterUserAction(); 1563 OnAfterUserAction();
1560 } 1564 }
1561 1565
1562 gfx::RenderText* Textfield::GetRenderText() const {
1563 return model_->render_text();
1564 }
1565
1566 base::string16 Textfield::GetSelectionClipboardText() const { 1566 base::string16 Textfield::GetSelectionClipboardText() const {
1567 base::string16 selection_clipboard_text; 1567 base::string16 selection_clipboard_text;
1568 ui::Clipboard::GetForCurrentThread()->ReadText( 1568 ui::Clipboard::GetForCurrentThread()->ReadText(
1569 ui::CLIPBOARD_TYPE_SELECTION, &selection_clipboard_text); 1569 ui::CLIPBOARD_TYPE_SELECTION, &selection_clipboard_text);
1570 return selection_clipboard_text; 1570 return selection_clipboard_text;
1571 } 1571 }
1572 1572
1573 void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) { 1573 void Textfield::ExecuteTextEditCommand(ui::TextEditCommand command) {
1574 DestroyTouchSelection(); 1574 DestroyTouchSelection();
1575 1575
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 UpdateAfterChange(true, true); 2040 UpdateAfterChange(true, true);
2041 } 2041 }
2042 OnAfterUserAction(); 2042 OnAfterUserAction();
2043 } 2043 }
2044 2044
2045 void Textfield::OnKeypressUnhandled() { 2045 void Textfield::OnKeypressUnhandled() {
2046 PlatformStyle::OnTextfieldKeypressUnhandled(); 2046 PlatformStyle::OnTextfieldKeypressUnhandled();
2047 } 2047 }
2048 2048
2049 } // namespace views 2049 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698