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

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

Issue 2164483006: [MacViews] Implemented text context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed tapted's comments and added a test Created 3 years, 10 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/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 630
631 context_menu_runner_.reset( 631 context_menu_runner_.reset(
632 new MenuRunner(&context_menu_contents_, MenuRunner::HAS_MNEMONICS | 632 new MenuRunner(&context_menu_contents_, MenuRunner::HAS_MNEMONICS |
633 MenuRunner::CONTEXT_MENU | 633 MenuRunner::CONTEXT_MENU |
634 MenuRunner::ASYNC)); 634 MenuRunner::ASYNC));
635 ignore_result(context_menu_runner_->RunMenuAt( 635 ignore_result(context_menu_runner_->RunMenuAt(
636 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPLEFT, 636 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPLEFT,
637 source_type)); 637 source_type));
638 } 638 }
639 639
640 bool Label::GetDecoratedWordAtPoint(const gfx::Point& point, 640 bool Label::GetDecoratedWordAndBaselineAtPoint(
641 gfx::DecoratedText* decorated_word, 641 const gfx::Point& point,
642 gfx::Point* baseline_point) { 642 gfx::DecoratedText* decorated_word,
643 gfx::Point* baseline_point) {
643 gfx::RenderText* render_text = GetRenderTextForSelectionController(); 644 gfx::RenderText* render_text = GetRenderTextForSelectionController();
644 return render_text 645 return render_text
645 ? render_text->GetDecoratedWordAtPoint(point, decorated_word, 646 ? render_text->GetDecoratedWordAndBaselineAtPoint(
646 baseline_point) 647 point, decorated_word, baseline_point)
647 : false; 648 : false;
648 } 649 }
649 650
651 bool Label::GetDecoratedTextAndBaselineFromSelection(
652 gfx::DecoratedText* decorated_text,
653 gfx::Point* baseline_point) {
654 return false;
msw 2017/01/26 20:59:16 Should this be implemented in this CL, or should y
spqchan 2017/02/01 00:32:38 Implemented
655 }
656
650 gfx::RenderText* Label::GetRenderTextForSelectionController() { 657 gfx::RenderText* Label::GetRenderTextForSelectionController() {
651 return const_cast<gfx::RenderText*>( 658 return const_cast<gfx::RenderText*>(
652 static_cast<const Label*>(this)->GetRenderTextForSelectionController()); 659 static_cast<const Label*>(this)->GetRenderTextForSelectionController());
653 } 660 }
654 661
655 bool Label::IsReadOnly() const { 662 bool Label::IsReadOnly() const {
656 return true; 663 return true;
657 } 664 }
658 665
659 bool Label::SupportsDrag() const { 666 bool Label::SupportsDrag() const {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 .WriteText(GetSelectedText()); 1035 .WriteText(GetSelectedText());
1029 } 1036 }
1030 1037
1031 void Label::BuildContextMenuContents() { 1038 void Label::BuildContextMenuContents() {
1032 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); 1039 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY);
1033 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL, 1040 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL,
1034 IDS_APP_SELECT_ALL); 1041 IDS_APP_SELECT_ALL);
1035 } 1042 }
1036 1043
1037 } // namespace views 1044 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698