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

Issue 2696263002: Refactor ViewsDelegate and MD-ify the icon-to-text spacing for checkbox and radiobutton (Closed)

Created:
3 years, 10 months ago by kylix_rd
Modified:
3 years, 9 months ago
Reviewers:
Peter Kasting, sky
CC:
chromium-reviews, tfarina
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Refactor ViewsDelegate and MD-ify the icon-to-text spacing for checkbox and radiobutton. ViewsDelegate should have the layout related functions coalesced into a handful of functions which take an enum element for each metric. BUG=652024, 687349 Review-Url: https://codereview.chromium.org/2696263002 Cr-Commit-Position: refs/heads/master@{#456078} Committed: https://chromium.googlesource.com/chromium/src/+/c34b8926fd843300658dcdaec4c69c6967cf86c6

Patch Set 1 #

Patch Set 2 : Reduced ViewsDelegate layout/metric functions to only two functions #

Total comments: 7

Patch Set 3 : Fix unit_tests #

Patch Set 4 : Moved enums out of ViewsDelegate #

Patch Set 5 : Added GetDefaultSpacingMetric to ViewsDelegate to start process of hiding layout constants #

Total comments: 3

Patch Set 6 : Fix unit tests to use a ViewsDelegate to guard against crashes #

Total comments: 1

Patch Set 7 : Move TestViewsDelegate to actual test from the ancestor harness #

Patch Set 8 : Prefer embedded initialization over heap allocation for TestViewsDelegate #

Total comments: 33

Patch Set 9 : Moved GetDefaultSpacingMetric to ChromeViewsDelegate Refactor ReloadButtonTest to better conform to… #

Patch Set 10 : Merged with latest changes. #

Total comments: 2

Patch Set 11 : Rename SpacingMetric to DistanceMetric. Removed ICON_TO_TEXT in favor of existing element. #

Patch Set 12 : Use 'related control spacing' constant for icon-to-text spacing #

Total comments: 11

Patch Set 13 : Some final nits #

Patch Set 14 : Used ifdef instead of duplicated code for delegate initialization #

Unified diffs Side-by-side diffs Delta from patch set Stats (+220 lines, -183 lines) Patch
M chrome/browser/first_run/try_chrome_dialog_view.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +4 lines, -1 line 0 comments Download
M chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc View 1 2 3 4 5 6 7 2 chunks +2 lines, -0 lines 0 comments Download
M chrome/browser/ui/views/chrome_views_delegate.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +6 lines, -9 lines 0 comments Download
M chrome/browser/ui/views/chrome_views_delegate.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +67 lines, -49 lines 0 comments Download
M chrome/browser/ui/views/chrome_views_delegate_win.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +0 lines, -3 lines 0 comments Download
M chrome/browser/ui/views/extensions/media_galleries_dialog_views_unittest.cc View 1 2 3 4 5 6 7 2 chunks +2 lines, -0 lines 0 comments Download
M chrome/browser/ui/views/global_error_bubble_view_unittest.cc View 1 2 3 4 5 6 7 2 chunks +2 lines, -0 lines 0 comments Download
M chrome/browser/ui/views/harmony/layout_delegate.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +13 lines, -6 lines 0 comments Download
M chrome/browser/ui/views/toolbar/reload_button_unittest.cc View 1 2 3 4 5 6 7 8 9 10 9 chunks +25 lines, -17 lines 0 comments Download
M ui/views/bubble/bubble_dialog_delegate.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +3 lines, -6 lines 0 comments Download
M ui/views/bubble/bubble_frame_view.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/controls/button/label_button.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +4 lines, -4 lines 0 comments Download
M ui/views/controls/button/md_text_button.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +4 lines, -3 lines 0 comments Download
M ui/views/examples/dialog_example.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +4 lines, -2 lines 0 comments Download
M ui/views/layout/layout_constants.h View 1 2 3 4 5 11 2 chunks +2 lines, -2 lines 0 comments Download
M ui/views/views_delegate.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +34 lines, -30 lines 0 comments Download
M ui/views/views_delegate.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +32 lines, -36 lines 0 comments Download
M ui/views/window/dialog_client_view.cc View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +10 lines, -10 lines 0 comments Download
M ui/views/window/dialog_delegate.cc View 1 2 3 1 chunk +4 lines, -3 lines 0 comments Download

Messages

Total messages: 116 (69 generated)
kylix_rd
This CL covers refactoring of the ViewsDelegate in which all the various separate metric functions ...
3 years, 10 months ago (2017-02-17 16:52:26 UTC) #5
sky
I only looked at ui/views https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h File ui/views/layout/layout_constants.h (right): https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h#newcode88 ui/views/layout/layout_constants.h:88: constexpr int kIconTextSpacing = ...
3 years, 10 months ago (2017-02-17 20:50:46 UTC) #10
kylix_rd
https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h File ui/views/layout/layout_constants.h (right): https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h#newcode88 ui/views/layout/layout_constants.h:88: constexpr int kIconTextSpacing = 5; On 2017/02/17 20:50:46, sky ...
3 years, 10 months ago (2017-02-17 21:40:51 UTC) #13
sky
https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h File ui/views/layout/layout_constants.h (right): https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h#newcode88 ui/views/layout/layout_constants.h:88: constexpr int kIconTextSpacing = 5; On 2017/02/17 21:40:51, kylix_rd ...
3 years, 10 months ago (2017-02-17 22:39:03 UTC) #14
Peter Kasting
https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h File ui/views/layout/layout_constants.h (right): https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h#newcode88 ui/views/layout/layout_constants.h:88: constexpr int kIconTextSpacing = 5; On 2017/02/17 22:39:03, sky ...
3 years, 10 months ago (2017-02-18 00:52:58 UTC) #17
kylix_rd
Moved enum out of the ViewsDelegate class up to the views namespace. Merged with latest ...
3 years, 10 months ago (2017-02-23 15:13:40 UTC) #22
sky
On 2017/02/17 21:40:51, kylix_rd wrote: > https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h > File ui/views/layout/layout_constants.h (right): > > https://codereview.chromium.org/2696263002/diff/20001/ui/views/layout/layout_constants.h#newcode88 > ...
3 years, 10 months ago (2017-02-23 20:11:32 UTC) #23
Peter Kasting
On 2017/02/23 15:13:40, kylix_rd wrote: > Moved enum out of the ViewsDelegate class up to ...
3 years, 10 months ago (2017-02-23 22:45:48 UTC) #24
kylix_rd
On 2017/02/23 22:45:48, Peter Kasting wrote: > On 2017/02/23 15:13:40, kylix_rd wrote: > > Moved ...
3 years, 10 months ago (2017-02-24 14:07:25 UTC) #25
kylix_rd
Latest patch adds GetDefaultSpacingMetric() static function per suggestion from sky@
3 years, 10 months ago (2017-02-24 14:19:03 UTC) #28
sky
https://codereview.chromium.org/2696263002/diff/80001/chrome/browser/ui/views/harmony/layout_delegate.cc File chrome/browser/ui/views/harmony/layout_delegate.cc (right): https://codereview.chromium.org/2696263002/diff/80001/chrome/browser/ui/views/harmony/layout_delegate.cc#newcode62 chrome/browser/ui/views/harmony/layout_delegate.cc:62: return views::ViewsDelegate::GetDefaultSpacingMetric( I would rather see this code call ...
3 years, 10 months ago (2017-02-24 18:31:13 UTC) #31
kylix_rd
https://codereview.chromium.org/2696263002/diff/80001/chrome/browser/ui/views/harmony/layout_delegate.cc File chrome/browser/ui/views/harmony/layout_delegate.cc (right): https://codereview.chromium.org/2696263002/diff/80001/chrome/browser/ui/views/harmony/layout_delegate.cc#newcode62 chrome/browser/ui/views/harmony/layout_delegate.cc:62: return views::ViewsDelegate::GetDefaultSpacingMetric( On 2017/02/24 18:31:13, sky wrote: > I ...
3 years, 10 months ago (2017-02-24 19:04:20 UTC) #32
Peter Kasting
On 2017/02/24 14:07:25, kylix_rd wrote: > On 2017/02/23 22:45:48, Peter Kasting wrote: > > On ...
3 years, 10 months ago (2017-02-24 20:41:03 UTC) #33
kylix_rd
On 2017/02/24 20:41:03, Peter Kasting wrote: > On 2017/02/24 14:07:25, kylix_rd wrote: > > On ...
3 years, 10 months ago (2017-02-24 21:15:01 UTC) #34
Peter Kasting
On 2017/02/24 21:15:01, kylix_rd wrote: > On 2017/02/24 20:41:03, Peter Kasting wrote: > > On ...
3 years, 10 months ago (2017-02-24 23:15:55 UTC) #35
kylix_rd
On 2017/02/24 23:15:55, Peter Kasting wrote: > > > We should fix the tests so ...
3 years, 9 months ago (2017-02-27 21:54:49 UTC) #50
sky
On 2017/02/27 21:54:49, kylix_rd wrote: > On 2017/02/24 23:15:55, Peter Kasting wrote: > > > ...
3 years, 9 months ago (2017-02-27 23:44:33 UTC) #51
Peter Kasting
https://codereview.chromium.org/2696263002/diff/140001/chrome/test/base/chrome_render_view_host_test_harness.h File chrome/test/base/chrome_render_view_host_test_harness.h (right): https://codereview.chromium.org/2696263002/diff/140001/chrome/test/base/chrome_render_view_host_test_harness.h#newcode34 chrome/test/base/chrome_render_view_host_test_harness.h:34: std::unique_ptr<views::TestViewsDelegate> views_delegate_; Yeah, pretty sure this can't be here, ...
3 years, 9 months ago (2017-02-28 02:44:04 UTC) #52
kylix_rd
On 2017/02/27 23:44:33, sky wrote: > On 2017/02/27 21:54:49, kylix_rd wrote: > > On 2017/02/24 ...
3 years, 9 months ago (2017-02-28 15:08:26 UTC) #53
kylix_rd
On 2017/02/28 15:08:26, kylix_rd wrote: > On 2017/02/27 23:44:33, sky wrote: > > On 2017/02/27 ...
3 years, 9 months ago (2017-02-28 17:21:49 UTC) #57
kylix_rd
Fixed Android build failure and change initialization of the TestViewsDelegate from heap allocated to embedded ...
3 years, 9 months ago (2017-02-28 17:41:24 UTC) #58
sky
https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/toolbar/reload_button_unittest.cc File chrome/browser/ui/views/toolbar/reload_button_unittest.cc (right): https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/toolbar/reload_button_unittest.cc#newcode5 chrome/browser/ui/views/toolbar/reload_button_unittest.cc:5: #include "chrome/browser/ui/views/toolbar/reload_button.h" newline between 5/6 (see style guide for ...
3 years, 9 months ago (2017-02-28 20:11:52 UTC) #63
Peter Kasting
https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.cc File chrome/browser/ui/views/harmony/layout_delegate.cc (right): https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.cc#newcode48 chrome/browser/ui/views/harmony/layout_delegate.cc:48: views::SpacingMetric::RELATED_VERTICAL_CONTROL); Seems weird that a HORIZONTAL-type metric here would ...
3 years, 9 months ago (2017-03-01 06:32:37 UTC) #64
sky
https://codereview.chromium.org/2696263002/diff/200001/content/public/test/test_renderer_host.cc File content/public/test/test_renderer_host.cc (right): https://codereview.chromium.org/2696263002/diff/200001/content/public/test/test_renderer_host.cc#newcode268 content/public/test/test_renderer_host.cc:268: rvh_test_enabler_.reset(new RenderViewHostTestEnabler()); On 2017/03/01 06:32:36, Peter Kasting wrote: > ...
3 years, 9 months ago (2017-03-01 17:07:16 UTC) #65
kylix_rd
https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.cc File chrome/browser/ui/views/harmony/layout_delegate.cc (right): https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.cc#newcode48 chrome/browser/ui/views/harmony/layout_delegate.cc:48: views::SpacingMetric::RELATED_VERTICAL_CONTROL); On 2017/03/01 06:32:36, Peter Kasting wrote: > Seems ...
3 years, 9 months ago (2017-03-01 17:33:28 UTC) #68
Peter Kasting
(have not looked at new patch, on the run) https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.h File chrome/browser/ui/views/harmony/layout_delegate.h (right): https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.h#newcode52 chrome/browser/ui/views/harmony/layout_delegate.h:52: ...
3 years, 9 months ago (2017-03-01 23:32:24 UTC) #71
kylix_rd
On 2017/03/01 23:32:24, Peter Kasting wrote: > (have not looked at new patch, on the ...
3 years, 9 months ago (2017-03-02 18:11:05 UTC) #74
kylix_rd
On 2017/03/02 18:11:05, kylix_rd wrote: > On 2017/03/01 23:32:24, Peter Kasting wrote: > > (have ...
3 years, 9 months ago (2017-03-02 18:14:29 UTC) #75
Peter Kasting
On 2017/03/02 18:14:29, kylix_rd wrote: > On 2017/03/02 18:11:05, kylix_rd wrote: > > On 2017/03/01 ...
3 years, 9 months ago (2017-03-02 20:17:46 UTC) #78
kylix_rd
On 2017/03/02 20:17:46, Peter Kasting wrote: > On 2017/03/02 18:14:29, kylix_rd wrote: > > On ...
3 years, 9 months ago (2017-03-02 21:39:43 UTC) #79
Peter Kasting
On 2017/03/02 21:39:43, kylix_rd wrote: > On 2017/03/02 20:17:46, Peter Kasting wrote: > > On ...
3 years, 9 months ago (2017-03-02 22:06:41 UTC) #80
Peter Kasting
https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.h File chrome/browser/ui/views/harmony/layout_delegate.h (right): https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.h#newcode52 chrome/browser/ui/views/harmony/layout_delegate.h:52: // associated text. This includes checkboxes and radio buttons. ...
3 years, 9 months ago (2017-03-03 00:05:55 UTC) #81
kylix_rd
On 2017/03/03 00:05:55, Peter Kasting wrote: > https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.h > File chrome/browser/ui/views/harmony/layout_delegate.h (right): > > https://codereview.chromium.org/2696263002/diff/200001/chrome/browser/ui/views/harmony/layout_delegate.h#newcode52 ...
3 years, 9 months ago (2017-03-03 14:43:04 UTC) #82
kylix_rd
3 years, 9 months ago (2017-03-03 17:22:45 UTC) #84
Peter Kasting
On 2017/03/03 14:43:04, kylix_rd wrote: > On 2017/03/03 00:05:55, Peter Kasting wrote: > > After ...
3 years, 9 months ago (2017-03-04 00:24:40 UTC) #88
Peter Kasting
On 2017/03/04 00:24:40, Peter Kasting wrote: > I would say, make this particular usage use ...
3 years, 9 months ago (2017-03-04 00:57:40 UTC) #89
kylix_rd
On 2017/03/04 00:24:40, Peter Kasting wrote: > On 2017/03/03 14:43:04, kylix_rd wrote: > > On ...
3 years, 9 months ago (2017-03-08 17:52:53 UTC) #90
kylix_rd
This patch should incorporate the initial changes suggested by pkasting@. The rest will be a ...
3 years, 9 months ago (2017-03-08 18:38:55 UTC) #93
sky
ui/views LGTM
3 years, 9 months ago (2017-03-08 21:01:58 UTC) #96
Peter Kasting
LGTM https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/views/chrome_views_delegate_win.cc File chrome/browser/ui/views/chrome_views_delegate_win.cc (right): https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/views/chrome_views_delegate_win.cc#newcode112 chrome/browser/ui/views/chrome_views_delegate_win.cc:112: : in_autohide_edges_callback_(false), weak_factory_(this) { For this function, it ...
3 years, 9 months ago (2017-03-09 05:52:11 UTC) #97
kylix_rd
https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/views/chrome_views_delegate_win.cc File chrome/browser/ui/views/chrome_views_delegate_win.cc (right): https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/views/chrome_views_delegate_win.cc#newcode112 chrome/browser/ui/views/chrome_views_delegate_win.cc:112: : in_autohide_edges_callback_(false), weak_factory_(this) { On 2017/03/09 05:52:11, Peter Kasting ...
3 years, 9 months ago (2017-03-09 15:02:32 UTC) #100
Peter Kasting
https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/views/chrome_views_delegate_win.cc File chrome/browser/ui/views/chrome_views_delegate_win.cc (right): https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/views/chrome_views_delegate_win.cc#newcode112 chrome/browser/ui/views/chrome_views_delegate_win.cc:112: : in_autohide_edges_callback_(false), weak_factory_(this) { On 2017/03/09 15:02:31, kylix_rd wrote: ...
3 years, 9 months ago (2017-03-09 18:26:48 UTC) #103
kylix_rd
This should address the last concern. Went with a small #if..#else block in chrome_views_delegate.cc and ...
3 years, 9 months ago (2017-03-10 15:10:40 UTC) #106
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/2696263002/320001
3 years, 9 months ago (2017-03-10 16:31:48 UTC) #111
commit-bot: I haz the power
Committed patchset #14 (id:320001) as https://chromium.googlesource.com/chromium/src/+/c34b8926fd843300658dcdaec4c69c6967cf86c6
3 years, 9 months ago (2017-03-10 16:39:36 UTC) #114
Peter Kasting
https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/views/chrome_views_delegate_win.cc File chrome/browser/ui/views/chrome_views_delegate_win.cc (right): https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/views/chrome_views_delegate_win.cc#newcode112 chrome/browser/ui/views/chrome_views_delegate_win.cc:112: : in_autohide_edges_callback_(false), weak_factory_(this) { On 2017/03/10 15:10:40, kylix_rd wrote: ...
3 years, 9 months ago (2017-03-10 20:44:54 UTC) #115
kylix_rd
3 years, 9 months ago (2017-03-10 22:03:09 UTC) #116
Message was sent while issue was closed.
On 2017/03/10 20:44:54, Peter Kasting wrote:
>
https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/view...
> File chrome/browser/ui/views/chrome_views_delegate_win.cc (right):
> 
>
https://codereview.chromium.org/2696263002/diff/280001/chrome/browser/ui/view...
> chrome/browser/ui/views/chrome_views_delegate_win.cc:112: :
> in_autohide_edges_callback_(false), weak_factory_(this) {
> On 2017/03/10 15:10:40, kylix_rd wrote:
> > On 2017/03/09 18:26:48, Peter Kasting wrote:
> > > On 2017/03/09 15:02:31, kylix_rd wrote:
> > > > On 2017/03/09 05:52:11, Peter Kasting wrote:
> > > > > For this function, it looks like the only reason it needs to be in
this
> > file
> > > > is
> > > > > because of the member references to win-only members.  But as a
> > consequence,
> > > > we
> > > > > need to duplicate the body of the function and the file-local
> > > |views_delegate|
> > > > > object into this file.  I suggest removing this, and instead in the
> header
> > > > that
> > > > > declares these members, using default member initializers to avoid the
> > need
> > > to
> > > > > give a member initializer list in any C++ file.
> > > > 
> > > > Can weak_factory_ be initialized with "this" using the default member
> > > > initializers?
> > > 
> > > It should be able to, AFAIK.  Such initializers are basically expressions
> that
> > > run in the context of the constructor when it executes, unless they're
> > > overridden by an explicit member initializer.
> > > 
> > > > Because of the difference constructor and that it references
> > > > views_delegate, the other methods which also reference it must also be
> moved
> > > > since views_delegate has no public linkage.
> > > 
> > > Ah, right.  That answers my other question.
> > > 
> > > Yes, I'd try to do "= this" in the header, to avoid the need for all this.

> If
> > > that doesn't work, I'd use an #ifdef in the cross-platform .cc, since on
> > balance
> > > that seems better than having to hoist so much other duplicated stuff to
> this
> > > file.
> > 
> > weak_factory_ takes "this" as a constructor parameter, so a simple
assignment
> > won't work (tried it).
> 
> Oh, due to the constructor being marked explicit?
> 
> If so it might have worked to do "=
> base::WeakPtrFactory<ChromeViewsDelegate>(this)".  But that's kind of ugly. 
Up
> to you if you think it would be a win and want to try it in a future CL :)

Yes. Really ugly :). I might try it merely for my own edification. Not a fan of
the #if either, but I find that a little more palatable.

Powered by Google App Engine
This is Rietveld 408576698