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

Issue 2413223003: Views:: Make Labels support text selection. (Closed)

Created:
4 years, 2 months ago by karandeepb
Modified:
4 years, 1 month ago
Reviewers:
tapted, sky, msw
CC:
chromium-reviews, yusukes+watch_chromium.org, derat+watch_chromium.org, tfarina, shuchen+watch_chromium.org, nona+watch_chromium.org, mac-reviews_chromium.org, James Su, chrome-apps-syd-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Views:: Make Labels support text selection. This CL is a follow-up to r427604 which extracted the text selection logic from views::Textfield and introduced the SelectionController class. This CL makes views::Label implement the SelectionControllerDelegate interface. As a result, single-line views::Label now support text selection. Some of the member functions in the Label class which do not change the external state of the Label are made const. This is made possible by making the render text instances that are used for drawing, mutable. A new test fixture class is also added for testing Labels. Existing tests are modified to use it, and new tests are added to test the text selection behavior. Support for copying and dragging selected text and text selection in multi-line views::Label will be added subsequently. Doc= https://docs.google.com/a/google.com/document/d/1JTjY8RLE84hxubCAouHuD6xVtvuMnzbqSDZyf_4N6tY/edit?usp=sharing BUG=630365, 437993 TEST= Launch views_examples_with_content_exe. Select Labels from the dropdown. Verify that text selection in the label with the text "A label supporting text selection." works properly. On Mac, also pass the --enable-harfbuzz-rendertext flag. Committed: https://crrev.com/8e225043e0f7aa5b951289e15b78c83aee7fda9d Cr-Commit-Position: refs/heads/master@{#430461}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Rebase. #

Patch Set 3 : Rebase. #

Patch Set 4 : -- #

Patch Set 5 : Make HasSelection const. #

Patch Set 6 : Rebase. #

Patch Set 7 : -- #

Total comments: 18

Patch Set 8 : Address comments by msw@. #

Patch Set 9 : Tests. #

Patch Set 10 : Rebase. #

Patch Set 11 : Cleanup. More tests. #

Total comments: 40

Patch Set 12 : Address comments. #

Total comments: 8

Patch Set 13 : Address comments. #

Total comments: 6

Patch Set 14 : Fix text selection background color on Windows. #

Total comments: 1

Patch Set 15 : Rebase #

Patch Set 16 : Rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+905 lines, -308 lines) Patch
M chrome/browser/ui/libgtkui/native_theme_gtk.cc View 1 2 3 4 5 6 7 8 9 1 chunk +4 lines, -0 lines 0 comments Download
M ui/gfx/render_text.h View 1 2 3 4 5 6 1 chunk +3 lines, -0 lines 0 comments Download
M ui/gfx/render_text_harfbuzz.h View 1 chunk +1 line, -0 lines 0 comments Download
M ui/gfx/render_text_harfbuzz.cc View 1 2 3 4 1 chunk +5 lines, -0 lines 0 comments Download
M ui/gfx/render_text_mac.h View 1 chunk +1 line, -0 lines 0 comments Download
M ui/gfx/render_text_mac.mm View 6 1 chunk +4 lines, -0 lines 0 comments Download
M ui/native_theme/common_theme.cc View 1 2 3 4 5 6 5 chunks +14 lines, -9 lines 0 comments Download
M ui/native_theme/native_theme.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +2 lines, -0 lines 0 comments Download
M ui/native_theme/native_theme_dark_aura.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +5 lines, -2 lines 0 comments Download
M ui/native_theme/native_theme_mac.mm View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +3 lines, -0 lines 0 comments Download
M ui/native_theme/native_theme_win.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +6 lines, -0 lines 0 comments Download
M ui/views/controls/label.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 6 chunks +91 lines, -9 lines 0 comments Download
M ui/views/controls/label.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 18 chunks +272 lines, -11 lines 0 comments Download
M ui/views/controls/label_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 chunks +456 lines, -261 lines 0 comments Download
M ui/views/controls/link.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M ui/views/controls/link.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +4 lines, -0 lines 0 comments Download
M ui/views/controls/textfield/textfield.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M ui/views/controls/textfield/textfield.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +4 lines, -5 lines 0 comments Download
M ui/views/controls/textfield/textfield_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/examples/label_example.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +4 lines, -0 lines 0 comments Download
M ui/views/selection_controller.cc View 1 2 3 4 5 6 7 8 9 10 11 12 4 chunks +14 lines, -4 lines 0 comments Download
M ui/views/selection_controller_delegate.h View 1 2 3 4 5 6 1 chunk +4 lines, -1 line 0 comments Download
M ui/views/style/platform_style.h View 1 2 3 4 5 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/style/platform_style.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +1 line, -1 line 0 comments Download
M ui/views/style/platform_style_mac.mm View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download

Dependent Patchsets:

Messages

Total messages: 122 (103 generated)
karandeepb
PTAL. This still needs some work. Will be adding tests subsequently. https://codereview.chromium.org/2413223003/diff/1/ui/views/controls/label.cc File ui/views/controls/label.cc (right): ...
4 years, 2 months ago (2016-10-14 09:31:34 UTC) #8
karandeepb
PTAL msw@. Still need to add tests. https://codereview.chromium.org/2413223003/diff/340001/ui/views/controls/label.cc File ui/views/controls/label.cc (right): https://codereview.chromium.org/2413223003/diff/340001/ui/views/controls/label.cc#newcode521 ui/views/controls/label.cc:521: // TODO(karandeepb): ...
4 years, 1 month ago (2016-10-27 07:31:54 UTC) #53
msw
Nice work! I have mostly minor comments and questions. https://codereview.chromium.org/2413223003/diff/340001/ui/views/controls/label.cc File ui/views/controls/label.cc (right): https://codereview.chromium.org/2413223003/diff/340001/ui/views/controls/label.cc#newcode493 ui/views/controls/label.cc:493: ...
4 years, 1 month ago (2016-10-28 06:30:26 UTC) #56
karandeepb
PTAL msw@. Thanks. https://codereview.chromium.org/2413223003/diff/340001/ui/views/controls/label.cc File ui/views/controls/label.cc (right): https://codereview.chromium.org/2413223003/diff/340001/ui/views/controls/label.cc#newcode493 ui/views/controls/label.cc:493: return GetRenderTextForSelectionController() ? GetNativeIBeamCursor() On 2016/10/28 ...
4 years, 1 month ago (2016-11-01 11:06:25 UTC) #77
msw
https://codereview.chromium.org/2413223003/diff/340001/ui/views/controls/label.cc File ui/views/controls/label.cc (right): https://codereview.chromium.org/2413223003/diff/340001/ui/views/controls/label.cc#newcode538 ui/views/controls/label.cc:538: bool Label::OnMouseDragged(const ui::MouseEvent& event) { On 2016/11/01 11:06:25, karandeepb ...
4 years, 1 month ago (2016-11-01 23:42:22 UTC) #82
karandeepb
PTAL msw@. https://codereview.chromium.org/2413223003/diff/540001/ui/views/controls/label.cc File ui/views/controls/label.cc (right): https://codereview.chromium.org/2413223003/diff/540001/ui/views/controls/label.cc#newcode581 ui/views/controls/label.cc:581: // Todo(karandeepb): Labels should support dragging selected ...
4 years, 1 month ago (2016-11-02 06:29:38 UTC) #89
msw
lgtm
4 years, 1 month ago (2016-11-03 01:41:13 UTC) #90
sky
https://codereview.chromium.org/2413223003/diff/580001/ui/views/controls/label.cc File ui/views/controls/label.cc (right): https://codereview.chromium.org/2413223003/diff/580001/ui/views/controls/label.cc#newcode262 ui/views/controls/label.cc:262: selection_controller_.reset(new SelectionController(this)); MakeUnique. https://codereview.chromium.org/2413223003/diff/580001/ui/views/controls/label.cc#newcode264 ui/views/controls/label.cc:264: // On Linux, update ...
4 years, 1 month ago (2016-11-03 03:23:21 UTC) #91
karandeepb
PTAL sky@. https://codereview.chromium.org/2413223003/diff/580001/ui/views/controls/label.cc File ui/views/controls/label.cc (right): https://codereview.chromium.org/2413223003/diff/580001/ui/views/controls/label.cc#newcode262 ui/views/controls/label.cc:262: selection_controller_.reset(new SelectionController(this)); On 2016/11/03 03:23:20, sky wrote: ...
4 years, 1 month ago (2016-11-03 10:38:56 UTC) #96
sky
https://codereview.chromium.org/2413223003/diff/600001/ui/views/controls/label.cc File ui/views/controls/label.cc (right): https://codereview.chromium.org/2413223003/diff/600001/ui/views/controls/label.cc#newcode820 ui/views/controls/label.cc:820: void Label::ApplyTextColors() const { Why are you making this ...
4 years, 1 month ago (2016-11-03 17:16:26 UTC) #97
karandeepb
PTAL sky@. https://codereview.chromium.org/2413223003/diff/600001/ui/views/controls/label.cc File ui/views/controls/label.cc (right): https://codereview.chromium.org/2413223003/diff/600001/ui/views/controls/label.cc#newcode820 ui/views/controls/label.cc:820: void Label::ApplyTextColors() const { On 2016/11/03 17:16:25, ...
4 years, 1 month ago (2016-11-04 00:21:55 UTC) #98
sky
LGTM
4 years, 1 month ago (2016-11-04 15:26:24 UTC) #99
karandeepb
PTAL sky@. Had to make a small change for Windows. https://codereview.chromium.org/2413223003/diff/620001/ui/native_theme/native_theme_win.cc File ui/native_theme/native_theme_win.cc (right): https://codereview.chromium.org/2413223003/diff/620001/ui/native_theme/native_theme_win.cc#newcode557 ...
4 years, 1 month ago (2016-11-07 04:06:36 UTC) #108
sky
SLGTM
4 years, 1 month ago (2016-11-07 16:56:55 UTC) #109
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2413223003/640001
4 years, 1 month ago (2016-11-07 23:43:23 UTC) #112
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presubmit/builds/298965)
4 years, 1 month ago (2016-11-07 23:55:50 UTC) #114
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2413223003/680001
4 years, 1 month ago (2016-11-08 00:21:12 UTC) #118
commit-bot: I haz the power
Committed patchset #16 (id:680001)
4 years, 1 month ago (2016-11-08 01:21:12 UTC) #120
commit-bot: I haz the power
4 years, 1 month ago (2016-11-08 01:33:21 UTC) #122
Message was sent while issue was closed.
Patchset 16 (id:??) landed as
https://crrev.com/8e225043e0f7aa5b951289e15b78c83aee7fda9d
Cr-Commit-Position: refs/heads/master@{#430461}

Powered by Google App Engine
This is Rietveld 408576698