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

Issue 1220793010: [ui/base;css] adding string template expression replacement (Closed)

Created:
5 years, 5 months ago by dschuyler
Modified:
4 years, 10 months ago
Reviewers:
Nico, Dan Beam, Evan Stade
CC:
chromium-reviews, erikwright+watch_chromium.org, jshin+watch_chromium.org, groby-ooo-7-16, Evan Stade
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[ui/base;css] adding string template expression replacement This CL provides a string replacement scheme using expressions of the form ${foo}, where foo is the name of a tag to be replaced. Several .css files in the CL have been converted to use this templating scheme rather than the numbered scheme ($1, $2, $3, etc.) previously used. While the code is initially intended to be used for ui/css files, it would be generally useful to any code working with string data. BUG=506009 Committed: https://crrev.com/6c937646c650fdded550560a6d443a7dae846819 Cr-Commit-Position: refs/heads/master@{#339215}

Patch Set 1 #

Patch Set 2 : added comment #

Total comments: 4

Patch Set 3 : comment change; merge with master #

Total comments: 6

Patch Set 4 : changed text_default.css and new_tab_theme.css to use replacement map #

Patch Set 5 : removed unsed vars; changed replace placeholder loop #

Patch Set 6 : removed unneeded comments #

Patch Set 7 : changed ReplaceTemplateExpressions name #

Patch Set 8 : changing incognito css to use template expressions #

Patch Set 9 : moved ReplaceTemplateExpressions code to ui/base #

Patch Set 10 : Removing changes to base/strings #

Total comments: 16

Patch Set 11 : Removing test code #

Total comments: 9

Patch Set 12 : fix for gn #

Patch Set 13 : Alternate template expression replacement, using find #

Total comments: 7

Patch Set 14 : Fix for incognito window #

Total comments: 21

Patch Set 15 : removed string16 versions of template expansions #

Total comments: 13

Patch Set 16 : removed unneeded typename #

Patch Set 17 : removing one of the two replacement loops #

Patch Set 18 : changed unit tests #

Patch Set 19 : merge with master #

Total comments: 8

Patch Set 20 : removed dollar sign escape from template expressions #

Patch Set 21 : better use of StringPiece in template expressions #

Total comments: 17

Patch Set 22 : removed include #

Patch Set 23 : moved presubmit test, test #

Patch Set 24 : crashing on invalid template expression #

Total comments: 8

Patch Set 25 : review changes #

Total comments: 4

Patch Set 26 : review changes #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+204 lines, -114 lines) Patch
M chrome/browser/resources/ntp4/new_incognito_tab_theme.css View 1 2 3 4 5 6 7 8 9 10 1 chunk +6 lines, -6 lines 0 comments Download
M chrome/browser/resources/ntp4/new_tab_theme.css View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +28 lines, -28 lines 1 comment Download
M chrome/browser/test_presubmit.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/browser/ui/webui/ntp/ntp_resource_cache.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 9 chunks +35 lines, -70 lines 0 comments Download
M chrome/browser/web_dev_style/css_checker.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +8 lines, -1 line 0 comments Download
M ui/base/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +3 lines, -0 lines 0 comments Download
A ui/base/template_expressions.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 chunk +28 lines, -0 lines 0 comments Download
A ui/base/template_expressions.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 chunk +42 lines, -0 lines 0 comments Download
A ui/base/template_expressions_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 chunk +36 lines, -0 lines 0 comments Download
M ui/base/ui_base.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +3 lines, -0 lines 0 comments Download
M ui/base/ui_base_tests.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -0 lines 0 comments Download
M ui/base/webui/web_ui_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +6 lines, -5 lines 0 comments Download
M ui/webui/resources/css/text_defaults.css View 1 2 3 1 chunk +4 lines, -4 lines 0 comments Download

Messages

Total messages: 57 (5 generated)
dschuyler
added comment
5 years, 5 months ago (2015-07-01 23:57:10 UTC) #1
dschuyler
5 years, 5 months ago (2015-07-02 01:42:59 UTC) #3
Dan Beam
you'll need a base/ OWNER to tell you if this actually belongs in base/ or ...
5 years, 5 months ago (2015-07-02 02:10:17 UTC) #4
dschuyler
comment change; merge with master
5 years, 5 months ago (2015-07-07 00:09:14 UTC) #5
Dan Beam
https://codereview.chromium.org/1220793010/diff/40001/base/strings/string_util.cc File base/strings/string_util.cc (right): https://codereview.chromium.org/1220793010/diff/40001/base/strings/string_util.cc#newcode881 base/strings/string_util.cc:881: i != format_string.end(); ++i) { please remove auto-increment, IMO ...
5 years, 5 months ago (2015-07-07 02:23:31 UTC) #6
Evan Stade
before you get much further you should make sure a base/ OWNER is okay with ...
5 years, 5 months ago (2015-07-07 17:15:17 UTC) #8
Dan Beam
On 2015/07/07 17:15:17, Evan Stade wrote: > before you get much further you should make ...
5 years, 5 months ago (2015-07-07 17:26:38 UTC) #9
arv (Not doing code reviews)
Drive by... How will this work/conflict with ES'15 template literals?
5 years, 5 months ago (2015-07-07 22:31:44 UTC) #10
Dan Beam
On 2015/07/07 22:31:44, arv wrote: > Drive by... > > How will this work/conflict with ...
5 years, 5 months ago (2015-07-07 22:34:24 UTC) #11
dschuyler
changed text_default.css and new_tab_theme.css to use replacement map
5 years, 5 months ago (2015-07-07 22:58:31 UTC) #12
dschuyler
https://codereview.chromium.org/1220793010/diff/20001/base/strings/string_util.h File base/strings/string_util.h (right): https://codereview.chromium.org/1220793010/diff/20001/base/strings/string_util.h#newcode522 base/strings/string_util.h:522: // Replace ${foo} in the format string with the ...
5 years, 5 months ago (2015-07-07 23:05:30 UTC) #14
Nico
does this have to be in base? (see text in base/OWNERS)
5 years, 5 months ago (2015-07-07 23:08:11 UTC) #15
Dan Beam
On 2015/07/07 23:08:11, Nico wrote: > does this have to be in base? (see text ...
5 years, 5 months ago (2015-07-07 23:08:47 UTC) #16
dschuyler
On 2015/07/07 23:08:47, Dan Beam wrote: > On 2015/07/07 23:08:11, Nico wrote: > > does ...
5 years, 5 months ago (2015-07-07 23:19:08 UTC) #17
dschuyler
removed unsed vars; changed replace placeholder loop
5 years, 5 months ago (2015-07-07 23:23:23 UTC) #18
dschuyler
removed unneeded comments
5 years, 5 months ago (2015-07-07 23:29:10 UTC) #19
Nico
On 2015/07/07 23:08:47, Dan Beam wrote: > On 2015/07/07 23:08:11, Nico wrote: > > does ...
5 years, 5 months ago (2015-07-07 23:36:27 UTC) #20
dschuyler
On 2015/07/07 23:36:27, Nico wrote: > On 2015/07/07 23:08:47, Dan Beam wrote: > > On ...
5 years, 5 months ago (2015-07-08 01:24:50 UTC) #21
Nico
On 2015/07/08 01:24:50, dschuyler wrote: > On 2015/07/07 23:36:27, Nico wrote: > > On 2015/07/07 ...
5 years, 5 months ago (2015-07-08 03:05:21 UTC) #22
Dan Beam
On 2015/07/08 03:05:21, Nico wrote: > On 2015/07/08 01:24:50, dschuyler wrote: > > On 2015/07/07 ...
5 years, 5 months ago (2015-07-08 16:10:45 UTC) #23
Dan Beam
in talking more with dschuyler@ about this, it seems that $# is wat better for ...
5 years, 5 months ago (2015-07-08 18:36:32 UTC) #24
dschuyler
This new patch moves the replacement code out of base and into ui/base.
5 years, 5 months ago (2015-07-09 19:12:05 UTC) #25
Dan Beam
this is looking ~pretty cool~ https://codereview.chromium.org/1220793010/diff/180001/chrome/browser/resources/ntp4/new_incognito_tab_theme.css File chrome/browser/resources/ntp4/new_incognito_tab_theme.css (right): https://codereview.chromium.org/1220793010/diff/180001/chrome/browser/resources/ntp4/new_incognito_tab_theme.css#newcode17 chrome/browser/resources/ntp4/new_incognito_tab_theme.css:17: } don't mean to ...
5 years, 5 months ago (2015-07-09 19:26:01 UTC) #26
Nico
Pretty cool. ui/base seems like a nice place. Please document clearly in the CL description ...
5 years, 5 months ago (2015-07-09 19:57:46 UTC) #27
dschuyler
I'm looking into the build failures... I need to work out the gyp and gn ...
5 years, 5 months ago (2015-07-14 00:56:18 UTC) #28
dschuyler
The try bots are all green, so hopefully that means I've got the gyp and ...
5 years, 5 months ago (2015-07-14 16:45:36 UTC) #29
Dan Beam
https://codereview.chromium.org/1220793010/diff/260001/chrome/browser/resources/ntp4/new_tab_theme.css File chrome/browser/resources/ntp4/new_tab_theme.css (right): https://codereview.chromium.org/1220793010/diff/260001/chrome/browser/resources/ntp4/new_tab_theme.css#newcode7 chrome/browser/resources/ntp4/new_tab_theme.css:7: background-color: ${colorBackground}; /* COLOR_NTP_BACKGROUND */ are these comments now ...
5 years, 5 months ago (2015-07-14 17:14:36 UTC) #30
dschuyler
https://codereview.chromium.org/1220793010/diff/260001/chrome/browser/resources/ntp4/new_tab_theme.css File chrome/browser/resources/ntp4/new_tab_theme.css (right): https://codereview.chromium.org/1220793010/diff/260001/chrome/browser/resources/ntp4/new_tab_theme.css#newcode7 chrome/browser/resources/ntp4/new_tab_theme.css:7: background-color: ${colorBackground}; /* COLOR_NTP_BACKGROUND */ On 2015/07/14 17:14:35, Dan ...
5 years, 5 months ago (2015-07-14 21:05:31 UTC) #31
Dan Beam
looking pretty good, need to remove one of those methods, though https://codereview.chromium.org/1220793010/diff/280001/chrome/browser/resources/ntp4/new_tab_theme.css File chrome/browser/resources/ntp4/new_tab_theme.css (left): ...
5 years, 5 months ago (2015-07-14 21:23:40 UTC) #32
Nico
Warning just in debug seems fine to me. https://www.chromium.org/developers/coding-style#TOC-CHECK-DCHECK-and-NOTREACHED- is the reference on this question. ...
5 years, 5 months ago (2015-07-14 21:44:18 UTC) #33
dschuyler
https://codereview.chromium.org/1220793010/diff/240001/ui/base/template_expressions.cc File ui/base/template_expressions.cc (right): https://codereview.chromium.org/1220793010/diff/240001/ui/base/template_expressions.cc#newcode19 ui/base/template_expressions.cc:19: #if 1 On 2015/07/14 21:44:18, Nico wrote: > On ...
5 years, 5 months ago (2015-07-15 00:11:04 UTC) #34
Dan Beam
https://codereview.chromium.org/1220793010/diff/280001/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc File chrome/browser/ui/webui/ntp/ntp_resource_cache.cc (right): https://codereview.chromium.org/1220793010/diff/280001/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc#newcode645 chrome/browser/ui/webui/ntp/ntp_resource_cache.cc:645: substitutions["colorTextCall"] = SkColorToRGBAString(color_text); On 2015/07/15 00:11:04, dschuyler wrote: > ...
5 years, 5 months ago (2015-07-15 16:36:25 UTC) #35
dschuyler
On 2015/07/15 16:36:25, Dan Beam wrote: > https://codereview.chromium.org/1220793010/diff/280001/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc > File chrome/browser/ui/webui/ntp/ntp_resource_cache.cc (right): > > https://codereview.chromium.org/1220793010/diff/280001/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc#newcode645 ...
5 years, 5 months ago (2015-07-15 16:55:47 UTC) #36
Dan Beam
On 2015/07/15 16:55:47, dschuyler wrote: > On 2015/07/15 16:36:25, Dan Beam wrote: > > > ...
5 years, 5 months ago (2015-07-15 17:47:39 UTC) #37
dschuyler
https://codereview.chromium.org/1220793010/diff/260001/ui/base/template_expressions_unittest.cc File ui/base/template_expressions_unittest.cc (right): https://codereview.chromium.org/1220793010/diff/260001/ui/base/template_expressions_unittest.cc#newcode13 ui/base/template_expressions_unittest.cc:13: substitutions[base::ASCIIToUTF16("one")] = base::ASCIIToUTF16("9a"); On 2015/07/14 17:14:35, Dan Beam wrote: ...
5 years, 5 months ago (2015-07-15 18:47:05 UTC) #38
Dan Beam
https://codereview.chromium.org/1220793010/diff/280001/chrome/browser/test_presubmit.py File chrome/browser/test_presubmit.py (right): https://codereview.chromium.org/1220793010/diff/280001/chrome/browser/test_presubmit.py#newcode59 chrome/browser/test_presubmit.py:59: self.ShouldPassCheck(line, self.checker.ClassesUseDashFormCheck) On 2015/07/14 21:23:40, Dan Beam wrote: > ...
5 years, 5 months ago (2015-07-15 18:56:41 UTC) #39
dschuyler
https://codereview.chromium.org/1220793010/diff/200001/ui/base/template_expressions.cc File ui/base/template_expressions.cc (right): https://codereview.chromium.org/1220793010/diff/200001/ui/base/template_expressions.cc#newcode27 ui/base/template_expressions.cc:27: while (i < format_string.end()) { On 2015/07/09 19:57:45, Nico ...
5 years, 5 months ago (2015-07-15 21:40:44 UTC) #40
Dan Beam
https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.cc File ui/base/template_expressions.cc (right): https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.cc#newcode20 ui/base/template_expressions.cc:20: while (i < format_string.end()) { why not format_string.find("${")?
5 years, 5 months ago (2015-07-15 21:56:09 UTC) #41
dschuyler
https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.cc File ui/base/template_expressions.cc (right): https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.cc#newcode20 ui/base/template_expressions.cc:20: while (i < format_string.end()) { On 2015/07/15 21:56:09, Dan ...
5 years, 5 months ago (2015-07-16 00:12:29 UTC) #42
Dan Beam
https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.cc File ui/base/template_expressions.cc (right): https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.cc#newcode8 ui/base/template_expressions.cc:8: #include "base/strings/utf_string_conversions.h" ^ needed? https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.cc#newcode22 ui/base/template_expressions.cc:22: size_t offset = ...
5 years, 5 months ago (2015-07-16 00:21:44 UTC) #43
dschuyler
https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.cc File ui/base/template_expressions.cc (right): https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.cc#newcode8 ui/base/template_expressions.cc:8: #include "base/strings/utf_string_conversions.h" On 2015/07/16 00:21:44, Dan Beam wrote: > ...
5 years, 5 months ago (2015-07-16 00:33:18 UTC) #44
dschuyler
https://codereview.chromium.org/1220793010/diff/280001/chrome/browser/test_presubmit.py File chrome/browser/test_presubmit.py (right): https://codereview.chromium.org/1220793010/diff/280001/chrome/browser/test_presubmit.py#newcode59 chrome/browser/test_presubmit.py:59: self.ShouldPassCheck(line, self.checker.ClassesUseDashFormCheck) On 2015/07/15 18:56:41, Dan Beam wrote: > ...
5 years, 5 months ago (2015-07-16 02:08:43 UTC) #45
Nico
lgtm once dan is happy (and with bugs below fixed) https://codereview.chromium.org/1220793010/diff/350014/ui/base/template_expressions.cc File ui/base/template_expressions.cc (right): https://codereview.chromium.org/1220793010/diff/350014/ui/base/template_expressions.cc#newcode20 ...
5 years, 5 months ago (2015-07-16 20:34:00 UTC) #46
Nico
Oh, and as said somewhere above, please update the cl description to clearly say where ...
5 years, 5 months ago (2015-07-16 20:34:24 UTC) #47
dschuyler
https://codereview.chromium.org/1220793010/diff/350014/ui/base/template_expressions.cc File ui/base/template_expressions.cc (right): https://codereview.chromium.org/1220793010/diff/350014/ui/base/template_expressions.cc#newcode20 ui/base/template_expressions.cc:20: if (*i == '$' && i < format_string.end() && ...
5 years, 5 months ago (2015-07-16 20:57:14 UTC) #48
Dan Beam
let the tools work for you: http://i.imgur.com/Z9XY4MD.png https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.h File ui/base/template_expressions.h (right): https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.h#newcode14 ui/base/template_expressions.h:14: #include "base/strings/string16.h" ...
5 years, 5 months ago (2015-07-17 01:57:18 UTC) #49
dschuyler
https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.h File ui/base/template_expressions.h (right): https://codereview.chromium.org/1220793010/diff/400001/ui/base/template_expressions.h#newcode14 ui/base/template_expressions.h:14: #include "base/strings/string16.h" On 2015/07/17 01:57:18, Dan Beam wrote: > ...
5 years, 5 months ago (2015-07-17 02:31:39 UTC) #50
Dan Beam
lgtm
5 years, 5 months ago (2015-07-17 02:59:23 UTC) #51
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1220793010/490001
5 years, 5 months ago (2015-07-17 03:43:22 UTC) #54
commit-bot: I haz the power
Committed patchset #26 (id:490001)
5 years, 5 months ago (2015-07-17 03:47:54 UTC) #55
commit-bot: I haz the power
Patchset 26 (id:??) landed as https://crrev.com/6c937646c650fdded550560a6d443a7dae846819 Cr-Commit-Position: refs/heads/master@{#339215}
5 years, 5 months ago (2015-07-17 03:48:57 UTC) #56
Dan Beam
4 years, 10 months ago (2016-01-29 23:27:56 UTC) #57
Message was sent while issue was closed.
https://codereview.chromium.org/1220793010/diff/490001/chrome/browser/resourc...
File chrome/browser/resources/ntp4/new_tab_theme.css (right):

https://codereview.chromium.org/1220793010/diff/490001/chrome/browser/resourc...
chrome/browser/resources/ntp4/new_tab_theme.css:50: background:
linear-gradient(top,
don't make functional changes while refactoring next time (this broke the page
switcher's background on chrome://apps and has made its way to stable)

Powered by Google App Engine
This is Rietveld 408576698