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

Issue 1819303002: StyledLabel: Added AddEmbeddedView method. (Closed)

Created:
4 years, 9 months ago by Matt Giuca
Modified:
4 years, 8 months ago
Reviewers:
msw, sadrul, sky
CC:
chromium-reviews, tfarina, chrome-apps-syd-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@applist-deprecation
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

StyledLabel: Added AddEmbeddedView method. Allows arbitrary views to be embedded within the label text. WORK IN PROGRESS. DO NOT SUBMIT. BUG=596799

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+81 lines, -25 lines) Patch
M ui/views/controls/styled_label.h View 3 chunks +15 lines, -4 lines 0 comments Download
M ui/views/controls/styled_label.cc View 9 chunks +66 lines, -21 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 11 (3 generated)
Matt Giuca
Hi Sadrul, what do you think of this in principle? (I haven't polished it up ...
4 years, 9 months ago (2016-03-22 08:05:13 UTC) #2
sadrul
+msw@, sky@ This looks like a nice feature to have, but may be very difficult ...
4 years, 8 months ago (2016-03-30 14:28:19 UTC) #4
sky
What is the specific use case that is needed? -Scott On Wed, Mar 30, 2016 ...
4 years, 8 months ago (2016-03-30 16:14:42 UTC) #5
Matt Giuca
On 2016/03/30 16:14:42, sky wrote: > What is the specific use case that is needed? ...
4 years, 8 months ago (2016-03-31 00:36:17 UTC) #6
sky
Embedding a view seems like a reasonable thing to want to do. That said, if ...
4 years, 8 months ago (2016-03-31 15:42:10 UTC) #7
sky
Also, for the record I don't like passing around views (at least in ui/views code) ...
4 years, 8 months ago (2016-03-31 16:14:59 UTC) #8
Matt Giuca
On 2016/03/31 15:42:10, sky wrote: > Embedding a view seems like a reasonable thing to ...
4 years, 8 months ago (2016-03-31 23:41:32 UTC) #10
sky
4 years, 8 months ago (2016-04-01 01:58:54 UTC) #11
Message was sent while issue was closed.
On Thu, Mar 31, 2016 at 4:41 PM,  <mgiuca@chromium.org> wrote:
> On 2016/03/31 15:42:10, sky wrote:
>> Embedding a view seems like a reasonable thing to want to do. That
>> said, if we don't have a real use now, why add the complexity?
>
> I did have a real use for it a week ago but now it's gotten too close to the
> deadline so I don't think we can use it any more (and as I said, it was only
> needed for 1 version).
>
> So I'm just closing this for now.
>
> BUT my concern is that someone will need something like this in the future
> and
> won't be able to find this and will just have to hack it somehow or
> reimplement
> this functionality. My main gripe with the Views system is that there is an
> understandable reluctance to add generally useful functionality for a single
> use
> case, and the pattern I see emerging is that all the clients end up hacking
> around or implementing their own versions of the general functionality. Here
> I
> saw a pattern that I've needed twice now so I thought I'd try to solve it in
> a
> general way.

I don't think there is a one size fits all for every scenario. In
chrome code we've generally tried to remove unused features as they
add complexity. If we need a feature though, I think it should be
implemented in the most ideal locations. Some times that is client
code, sometimes that is near the main code.

>> I
>> wouldn't want to expose the implementation details of textlayout to
>> consumers (meaning boxlayout or any sort of layout). If we add this
>> functionality I like specifying the views to add and that's all the
>> consumer need do.
>
> SGTM.
>
>> Also, for the record I don't like passing around views (at least in
>> ui/views code) via scoped_ptr. I say this as the ownership of views
>> changes depending upon set_client_owned. I realize in your patch you
>> made StyledLabel also invoke set_client_owned. That is extra confusing
>> as set_client_owned is intended for users of views, and not something
>> to change on a client supplied view.
>
> That is why I passed it as a scoped_ptr; then the StyledLabel becomes the
> undisputed single owner of the view and is allowed to do things like call
> set_client_owned --- StyledLabel is now the client, NOT whoever passed it in
> to
> AddEmbeddedView. I need to call set_client_owned on the view because every
> time
> StyledLabel re-layouts, it deletes all of its children and starts again. I
> need
> to make sure that all of the Labels that were created by the StyledLabel get
> deleted, but the embedded views stay alive and owned by the StyledLabel's
> vector
> of scoped_ptrs.

Again, set_client_owned is intended for clients and not something that
views should use internally (in most cases). I don't think scoped_ptr
is a good match with set_client_owned.

  -Scott

> https://codereview.chromium.org/1819303002/

-- 
You received this message because you are subscribed to the Google Groups
"Chromium-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698