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

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

Issue 2688883002: Revert [MacViews] Implemented text context menu (Closed)
Patch Set: 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
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/textfield/textfield.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 634
635 context_menu_runner_.reset( 635 context_menu_runner_.reset(
636 new MenuRunner(&context_menu_contents_, MenuRunner::HAS_MNEMONICS | 636 new MenuRunner(&context_menu_contents_, MenuRunner::HAS_MNEMONICS |
637 MenuRunner::CONTEXT_MENU | 637 MenuRunner::CONTEXT_MENU |
638 MenuRunner::ASYNC)); 638 MenuRunner::ASYNC));
639 ignore_result(context_menu_runner_->RunMenuAt( 639 ignore_result(context_menu_runner_->RunMenuAt(
640 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPLEFT, 640 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPLEFT,
641 source_type)); 641 source_type));
642 } 642 }
643 643
644 bool Label::GetDecoratedWordAndBaselineAtPoint( 644 bool Label::GetDecoratedWordAtPoint(const gfx::Point& point,
645 const gfx::Point& point, 645 gfx::DecoratedText* decorated_word,
646 gfx::DecoratedText* decorated_word, 646 gfx::Point* baseline_point) {
647 gfx::Point* baseline_point) {
648 gfx::RenderText* render_text = GetRenderTextForSelectionController(); 647 gfx::RenderText* render_text = GetRenderTextForSelectionController();
649 return render_text 648 return render_text
650 ? render_text->GetDecoratedWordAndBaselineAtPoint( 649 ? render_text->GetDecoratedWordAtPoint(point, decorated_word,
651 point, decorated_word, baseline_point) 650 baseline_point)
652 : false; 651 : false;
653 } 652 }
654 653
655 bool Label::GetDecoratedTextAndBaselineFromSelection(
656 gfx::DecoratedText* decorated_text,
657 gfx::Point* baseline_point) {
658 if (!selectable())
659 return false;
660
661 gfx::RenderText* render_text = GetRenderTextForSelectionController();
662 if (!render_text)
663 return false;
664
665 return render_text->GetDecoratedTextAndBaselineForRange(
666 render_text->selection(), decorated_text, baseline_point);
667 }
668
669 gfx::RenderText* Label::GetRenderTextForSelectionController() { 654 gfx::RenderText* Label::GetRenderTextForSelectionController() {
670 return const_cast<gfx::RenderText*>( 655 return const_cast<gfx::RenderText*>(
671 static_cast<const Label*>(this)->GetRenderTextForSelectionController()); 656 static_cast<const Label*>(this)->GetRenderTextForSelectionController());
672 } 657 }
673 658
674 bool Label::IsReadOnly() const { 659 bool Label::IsReadOnly() const {
675 return true; 660 return true;
676 } 661 }
677 662
678 bool Label::SupportsDrag() const { 663 bool Label::SupportsDrag() const {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 .WriteText(GetSelectedText()); 1032 .WriteText(GetSelectedText());
1048 } 1033 }
1049 1034
1050 void Label::BuildContextMenuContents() { 1035 void Label::BuildContextMenuContents() {
1051 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); 1036 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY);
1052 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL, 1037 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL,
1053 IDS_APP_SELECT_ALL); 1038 IDS_APP_SELECT_ALL);
1054 } 1039 }
1055 1040
1056 } // namespace views 1041 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/textfield/textfield.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698