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

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

Issue 2639493002: MacViews: Enable word lookup for selectable views::Labels and multi-line text. (Closed)
Patch Set: Address nits. Created 3 years, 11 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') | no next file » | 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 (tooltip_text_.empty() && !ShouldShowDefaultTooltip())) 388 (tooltip_text_.empty() && !ShouldShowDefaultTooltip()))
389 return NULL; 389 return NULL;
390 390
391 return HitTestPoint(point) ? this : NULL; 391 return HitTestPoint(point) ? this : NULL;
392 } 392 }
393 393
394 bool Label::CanProcessEventsWithinSubtree() const { 394 bool Label::CanProcessEventsWithinSubtree() const {
395 return !!GetRenderTextForSelectionController(); 395 return !!GetRenderTextForSelectionController();
396 } 396 }
397 397
398 WordLookupClient* Label::GetWordLookupClient() {
399 return this;
400 }
401
398 void Label::GetAccessibleNodeData(ui::AXNodeData* node_data) { 402 void Label::GetAccessibleNodeData(ui::AXNodeData* node_data) {
399 node_data->role = ui::AX_ROLE_STATIC_TEXT; 403 node_data->role = ui::AX_ROLE_STATIC_TEXT;
400 node_data->AddStateFlag(ui::AX_STATE_READ_ONLY); 404 node_data->AddStateFlag(ui::AX_STATE_READ_ONLY);
401 // Note that |render_text_| is never elided (see the comment in Init() too). 405 // Note that |render_text_| is never elided (see the comment in Init() too).
402 node_data->SetName(render_text_->GetDisplayText()); 406 node_data->SetName(render_text_->GetDisplayText());
403 } 407 }
404 408
405 bool Label::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const { 409 bool Label::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const {
406 if (!handles_tooltips_) 410 if (!handles_tooltips_)
407 return false; 411 return false;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 630
627 context_menu_runner_.reset( 631 context_menu_runner_.reset(
628 new MenuRunner(&context_menu_contents_, MenuRunner::HAS_MNEMONICS | 632 new MenuRunner(&context_menu_contents_, MenuRunner::HAS_MNEMONICS |
629 MenuRunner::CONTEXT_MENU | 633 MenuRunner::CONTEXT_MENU |
630 MenuRunner::ASYNC)); 634 MenuRunner::ASYNC));
631 ignore_result(context_menu_runner_->RunMenuAt( 635 ignore_result(context_menu_runner_->RunMenuAt(
632 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPLEFT, 636 GetWidget(), nullptr, gfx::Rect(point, gfx::Size()), MENU_ANCHOR_TOPLEFT,
633 source_type)); 637 source_type));
634 } 638 }
635 639
640 bool Label::GetDecoratedWordAtPoint(const gfx::Point& point,
641 gfx::DecoratedText* decorated_word,
642 gfx::Point* baseline_point) {
643 gfx::RenderText* render_text = GetRenderTextForSelectionController();
644 return render_text
645 ? render_text->GetDecoratedWordAtPoint(point, decorated_word,
646 baseline_point)
647 : false;
648 }
649
636 gfx::RenderText* Label::GetRenderTextForSelectionController() { 650 gfx::RenderText* Label::GetRenderTextForSelectionController() {
637 return const_cast<gfx::RenderText*>( 651 return const_cast<gfx::RenderText*>(
638 static_cast<const Label*>(this)->GetRenderTextForSelectionController()); 652 static_cast<const Label*>(this)->GetRenderTextForSelectionController());
639 } 653 }
640 654
641 bool Label::IsReadOnly() const { 655 bool Label::IsReadOnly() const {
642 return true; 656 return true;
643 } 657 }
644 658
645 bool Label::SupportsDrag() const { 659 bool Label::SupportsDrag() const {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 .WriteText(GetSelectedText()); 1028 .WriteText(GetSelectedText());
1015 } 1029 }
1016 1030
1017 void Label::BuildContextMenuContents() { 1031 void Label::BuildContextMenuContents() {
1018 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); 1032 context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY);
1019 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL, 1033 context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL,
1020 IDS_APP_SELECT_ALL); 1034 IDS_APP_SELECT_ALL);
1021 } 1035 }
1022 1036
1023 } // namespace views 1037 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698