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

Issue 1836483002: Fix up and rename VisibleMargins() in preparation for making use of it. (Closed)

Created:
4 years, 9 months ago by Peter Kasting
Modified:
4 years, 8 months ago
Reviewers:
danakj, Evan Stade
CC:
chromium-reviews, rsesek+watch_chromium.org, varkha
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix up and rename VisibleMargins() in preparation for making use of it. It turns out this function is currently unused (but tested), and its behavior is rather odd and inconsistent -- rather than report the "margins" around an image it reports the columns in which it finds visible pixels, and there are some bugs. I've revamped this to actually report the widths of any "margins" at the edges. I've also cleaned up and simplified the code and added more tests. I made one other seemingly-unconnected change, to paint_vector_icon.cc. This is because VisibleMargins() used to early-exit when HasRepresentation() returned false. I believe that caused problems if you called the function on an image for which you had not yet obtained any representations, because if GetRepresentation() would have succeeded (and then HasRepresentation would succeed), the function would basically flakily fail. To avoid this, I made it simply call GetRepresentation() instead, from which we can still detect when the returned representation is an empty "no representation" placeholder. However, this caused a different problem: if you called this on VECTOR_ICON_NONE, the vector painting code DCHECKed (because you shouldn't be painting that). After some consideration, I decided that it was OK for VectorIconSource::Draw() to be called, and simply paint nothing, with this value, while PaintVectorIcon() would still DCHECK if called directly. This allows GetRepresentation() to return an empty representation for VECTOR_ICON_NONE instead of crashing, which in turn allows calling GetVisibleMargins() on that, which is important in the upcoming patch where I'll make use of this because we'll be trying to call this on SkImages that may or may not be that icon under-the-hood. BUG=586423 TEST=none Committed: https://crrev.com/723dfe66b1985ff2178590b15d1cc63911300737 Cr-Commit-Position: refs/heads/master@{#384157}

Patch Set 1 #

Total comments: 8

Patch Set 2 : Review comments #

Total comments: 1

Patch Set 3 : Revert vector icon change #

Patch Set 4 : Add back check for HasRepresentation() #

Patch Set 5 : Resync #

Patch Set 6 : Resync #

Unified diffs Side-by-side diffs Delta from patch set Stats (+158 lines, -131 lines) Patch
M ui/gfx/image/image_util.h View 1 chunk +9 lines, -15 lines 0 comments Download
M ui/gfx/image/image_util.cc View 1 2 3 2 chunks +43 lines, -47 lines 0 comments Download
M ui/gfx/image/image_util_unittest.cc View 1 1 chunk +106 lines, -69 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 26 (11 generated)
Peter Kasting
estade: paint_vector_icon.cc -- see CL description for explanation danakj: rest
4 years, 9 months ago (2016-03-25 08:57:22 UTC) #2
danakj
LGTM https://codereview.chromium.org/1836483002/diff/1/ui/gfx/image/image_util.cc File ui/gfx/image/image_util.cc (right): https://codereview.chromium.org/1836483002/diff/1/ui/gfx/image/image_util.cc#newcode20 ui/gfx/image/image_util.cc:20: // Returns whether column |x| of |bitmap| has ...
4 years, 9 months ago (2016-03-25 23:35:28 UTC) #3
Peter Kasting
New snap not yet up https://codereview.chromium.org/1836483002/diff/1/ui/gfx/image/image_util.cc File ui/gfx/image/image_util.cc (right): https://codereview.chromium.org/1836483002/diff/1/ui/gfx/image/image_util.cc#newcode20 ui/gfx/image/image_util.cc:20: // Returns whether column ...
4 years, 9 months ago (2016-03-26 01:01:58 UTC) #4
Peter Kasting
New snap up to address Dana's comments (re-review not necessary).
4 years, 9 months ago (2016-03-26 04:45:02 UTC) #5
Evan Stade
On 2016/03/26 04:45:02, Peter Kasting wrote: > New snap up to address Dana's comments (re-review ...
4 years, 8 months ago (2016-03-28 19:32:46 UTC) #6
Peter Kasting
On 2016/03/28 19:32:46, Evan Stade wrote: > On 2016/03/26 04:45:02, Peter Kasting wrote: > > ...
4 years, 8 months ago (2016-03-29 01:38:17 UTC) #7
Evan Stade
https://codereview.chromium.org/1836483002/diff/20001/ui/gfx/paint_vector_icon.cc File ui/gfx/paint_vector_icon.cc (right): https://codereview.chromium.org/1836483002/diff/20001/ui/gfx/paint_vector_icon.cc#newcode401 ui/gfx/paint_vector_icon.cc:401: ImageSkia CreateVectorIconWithBadge(VectorIconId id, So we're calling this with id ...
4 years, 8 months ago (2016-03-29 03:04:14 UTC) #8
Peter Kasting
Thanks for the comment. I'll move this change to the other CL, add you as ...
4 years, 8 months ago (2016-03-29 06:39:34 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1836483002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1836483002/40001
4 years, 8 months ago (2016-03-29 06:40:08 UTC) #12
Peter Kasting
Actually, let me hold off committing this. I'm writing up a detailed analysis on the ...
4 years, 8 months ago (2016-03-29 07:20:13 UTC) #14
Peter Kasting
I've now re-added the check for HasRepresentation(), with the necessary changes to that function in ...
4 years, 8 months ago (2016-03-30 03:34:13 UTC) #15
commit-bot: I haz the power
This CL has an open dependency (Issue 1846513002 Patch 60001). Please resolve the dependency and ...
4 years, 8 months ago (2016-03-30 21:54:42 UTC) #20
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1836483002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1836483002/100001
4 years, 8 months ago (2016-03-30 23:35:11 UTC) #22
commit-bot: I haz the power
Committed patchset #6 (id:100001)
4 years, 8 months ago (2016-03-31 00:34:53 UTC) #24
commit-bot: I haz the power
4 years, 8 months ago (2016-03-31 00:35:52 UTC) #26
Message was sent while issue was closed.
Patchset 6 (id:??) landed as
https://crrev.com/723dfe66b1985ff2178590b15d1cc63911300737
Cr-Commit-Position: refs/heads/master@{#384157}

Powered by Google App Engine
This is Rietveld 408576698