|
|
DescriptionMove field-dependent code in ComputedStyleBase to Jinja macros.
When we're generating fields in ComputedStyleBase, there are cases
where the generated code depends on the field template. For example,
keyword fields may have different getters than platform type fields.
Instead of doing if-else statements inside the template which makes
it quite ugly, this patch moves that logic out into their own files
as Jinja macros. Each file defines Jinja macros that specify how a
field should be generated.
This patch adds a 'keyword' template for enums, 'flag' template for
bools, and 'monotonic_flag' for nonproperty flags that can't be set
to false.
Link to generated code:
https://gist.github.com/anonymous/93f5d3907e3515d0b50adf0107f3000e
Link to diff (see differences in 'initialUnique' and 'resetUnique'):
https://www.diffchecker.com/mikllVbf
BUG=628043
Review-Url: https://codereview.chromium.org/2693933003
Cr-Commit-Position: refs/heads/master@{#456095}
Committed: https://chromium.googlesource.com/chromium/src/+/6ce2feb35c970fe7d9557c851c016c6d6c8b1d39
Patch Set 1 #Patch Set 2 : Rebase #Patch Set 3 : One member per field #Patch Set 4 : Rebase #Patch Set 5 : Add missing files #Patch Set 6 : Rebase #Patch Set 7 : Rebase #Patch Set 8 : DRY #
Total comments: 1
Patch Set 9 : Add to build.gn #Patch Set 10 : Rebase #Messages
Total messages: 54 (31 generated)
Description was changed from ========== Move field-dependent template code from ComputedStyleBase to macros. When we're generating fields in ComputedStyleBase, there are cases where the generated code depends on the field template. For example, keyword fields may have different getters than platform type fields. Instead of doing if-else statements inside the template which makes it quite ugly, this patch moves that logic out into their own files as macros. Each file defines macros that specify how a field should be generated. This patch does not change behaviour. BUG=628043 ========== to ========== Move field-dependent template code from ComputedStyleBase to macros. When we're generating fields in ComputedStyleBase, there are cases where the generated code depends on the field template. For example, keyword fields may have different getters than platform type fields. Instead of doing if-else statements inside the template which makes it quite ugly, this patch moves that logic out into their own files as macros. Each file defines macros that specify how a field should be generated. This patch adds a 'keyword' template for enums, 'flag' template for bools, and 'monotonic_flag' for nonproperty flags that can't be set to false. This patch does not change behaviour. BUG=628043 ==========
The CQ bit was checked by shend@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by shend@chromium.org
The CQ bit was checked by shend@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...) ios-device-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device-xcode-...) ios-simulator-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator-xco...)
The CQ bit was checked by shend@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...) ios-device-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device-xcode-...) ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...) ios-simulator-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator-xco...)
The CQ bit was checked by shend@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
shend@chromium.org changed reviewers: + bugsnash@chromium.org
Hi Bugs, PTAL :)
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
On 2017/02/16 at 06:49:22, shend wrote: > Hi Bugs, PTAL :) Forgot to mention, I'm open to better names than 'monotonic_flag'.
On 2017/02/16 at 21:50:07, shend wrote: > On 2017/02/16 at 06:49:22, shend wrote: > > Hi Bugs, PTAL :) > > Forgot to mention, I'm open to better names than 'monotonic_flag'. Yeah, 'monotonic' isn't exactly an accurate description of the flag. Although I can't think of a name that is exactly accurate. The only things I can think of are things like 'isset' and 'unidirectional'.
bugsnash@chromium.org changed reviewers: + sashab@chromium.org
This patch introduces some duplication of templated code, which could make it difficult to maintain. I feel like it was better before, what do you think Sasha?
bugsnash@chromium.org changed reviewers: + meade@chromium.org - sashab@chromium.org
Forwarding this question to Eddy as Sasha is handing this project over to style team
On 2017/02/19 at 23:39:46, bugsnash wrote: > This patch introduces some duplication of templated code, which could make it difficult to maintain. I feel like it was better before, what do you think Sasha? I could reduce duplication by using template inheritance: http://flask.pocoo.org/docs/0.12/patterns/templateinheritance/ So I would create a base template with getters and setters and then extend that in the other templates. It might not look like we're doing much here, but a future patch https://codereview.chromium.org/2697953004 would look quite ugly if we don't split the logic up somehow.
On 2017/02/20 at 06:43:28, shend wrote: > On 2017/02/19 at 23:39:46, bugsnash wrote: > > This patch introduces some duplication of templated code, which could make it difficult to maintain. I feel like it was better before, what do you think Sasha? > > I could reduce duplication by using template inheritance: http://flask.pocoo.org/docs/0.12/patterns/templateinheritance/ > So I would create a base template with getters and setters and then extend that in the other templates. > > It might not look like we're doing much here, but a future patch https://codereview.chromium.org/2697953004 would look quite ugly if we don't split the logic up somehow. Oops, can't use template inheritance since I'm using a macro, but essentially I can create a base template that other macros call: {% import 'base.tmpl' as base %} {% macro decl_methods(field) -%} {% base.decl_methods(field) %} // other methods {%- endmacro %}
On 2017/02/20 at 07:03:29, shend wrote: > On 2017/02/20 at 06:43:28, shend wrote: > > On 2017/02/19 at 23:39:46, bugsnash wrote: > > > This patch introduces some duplication of templated code, which could make it difficult to maintain. I feel like it was better before, what do you think Sasha? > > > > I could reduce duplication by using template inheritance: http://flask.pocoo.org/docs/0.12/patterns/templateinheritance/ > > So I would create a base template with getters and setters and then extend that in the other templates. > > > > It might not look like we're doing much here, but a future patch https://codereview.chromium.org/2697953004 would look quite ugly if we don't split the logic up somehow. > > Oops, can't use template inheritance since I'm using a macro, but essentially I can create a base template that other macros call: > > {% import 'base.tmpl' as base %} > {% macro decl_methods(field) -%} > {% base.decl_methods(field) %} > // other methods > {%- endmacro %} I would be ok with calling base templates here to get rid of the duplication
On 2017/02/20 at 20:41:44, bugsnash wrote: > On 2017/02/20 at 07:03:29, shend wrote: > > On 2017/02/20 at 06:43:28, shend wrote: > > > On 2017/02/19 at 23:39:46, bugsnash wrote: > > > > This patch introduces some duplication of templated code, which could make it difficult to maintain. I feel like it was better before, what do you think Sasha? > > > > > > I could reduce duplication by using template inheritance: http://flask.pocoo.org/docs/0.12/patterns/templateinheritance/ > > > So I would create a base template with getters and setters and then extend that in the other templates. > > > > > > It might not look like we're doing much here, but a future patch https://codereview.chromium.org/2697953004 would look quite ugly if we don't split the logic up somehow. > > > > Oops, can't use template inheritance since I'm using a macro, but essentially I can create a base template that other macros call: > > > > {% import 'base.tmpl' as base %} > > {% macro decl_methods(field) -%} > > {% base.decl_methods(field) %} > > // other methods > > {%- endmacro %} > > I would be ok with calling base templates here to get rid of the duplication Ok, done. Let me know what you think.
On 2017/02/22 at 03:29:49, shend wrote: > On 2017/02/20 at 20:41:44, bugsnash wrote: > > On 2017/02/20 at 07:03:29, shend wrote: > > > On 2017/02/20 at 06:43:28, shend wrote: > > > > On 2017/02/19 at 23:39:46, bugsnash wrote: > > > > > This patch introduces some duplication of templated code, which could make it difficult to maintain. I feel like it was better before, what do you think Sasha? > > > > > > > > I could reduce duplication by using template inheritance: http://flask.pocoo.org/docs/0.12/patterns/templateinheritance/ > > > > So I would create a base template with getters and setters and then extend that in the other templates. > > > > > > > > It might not look like we're doing much here, but a future patch https://codereview.chromium.org/2697953004 would look quite ugly if we don't split the logic up somehow. > > > > > > Oops, can't use template inheritance since I'm using a macro, but essentially I can create a base template that other macros call: > > > > > > {% import 'base.tmpl' as base %} > > > {% macro decl_methods(field) -%} > > > {% base.decl_methods(field) %} > > > // other methods > > > {%- endmacro %} > > > > I would be ok with calling base templates here to get rid of the duplication > > Ok, done. Let me know what you think. Could you please link to sample generated code in the description?
https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl (right): https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl:1: {% import 'fields/base.tmpl' as base %} This template is identical to the flag template. How do we determine which methods are to be excluded?
On 2017/02/23 at 00:08:55, bugsnash wrote: > On 2017/02/22 at 03:29:49, shend wrote: > > On 2017/02/20 at 20:41:44, bugsnash wrote: > > > On 2017/02/20 at 07:03:29, shend wrote: > > > > On 2017/02/20 at 06:43:28, shend wrote: > > > > > On 2017/02/19 at 23:39:46, bugsnash wrote: > > > > > > This patch introduces some duplication of templated code, which could make it difficult to maintain. I feel like it was better before, what do you think Sasha? > > > > > > > > > > I could reduce duplication by using template inheritance: http://flask.pocoo.org/docs/0.12/patterns/templateinheritance/ > > > > > So I would create a base template with getters and setters and then extend that in the other templates. > > > > > > > > > > It might not look like we're doing much here, but a future patch https://codereview.chromium.org/2697953004 would look quite ugly if we don't split the logic up somehow. > > > > > > > > Oops, can't use template inheritance since I'm using a macro, but essentially I can create a base template that other macros call: > > > > > > > > {% import 'base.tmpl' as base %} > > > > {% macro decl_methods(field) -%} > > > > {% base.decl_methods(field) %} > > > > // other methods > > > > {%- endmacro %} > > > > > > I would be ok with calling base templates here to get rid of the duplication > > > > Ok, done. Let me know what you think. > > Could you please link to sample generated code in the description? Will do!
On 2017/02/23 at 00:13:34, bugsnash wrote: > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > File third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl (right): > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl:1: {% import 'fields/base.tmpl' as base %} > This template is identical to the flag template. How do we determine which methods are to be excluded? Yes, I'll eventually be adding more methods to the keywords template (if not I'll just merge the two templates). I'm not sure what you mean by which methods are excluded. With this setup, you can't really "exclude" methods. It is possible to split the "base.decl_methods" macro into "decl_getter" and "decl_setter" etc. so you can cherry pick what methods to include. Would that help?
On 2017/02/23 at 00:19:15, shend wrote: > On 2017/02/23 at 00:13:34, bugsnash wrote: > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > File third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl (right): > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl:1: {% import 'fields/base.tmpl' as base %} > > This template is identical to the flag template. How do we determine which methods are to be excluded? > > Yes, I'll eventually be adding more methods to the keywords template (if not I'll just merge the two templates). I'm not sure what you mean by which methods are excluded. With this setup, you can't really "exclude" methods. It is possible to split the "base.decl_methods" macro into "decl_getter" and "decl_setter" etc. so you can cherry pick what methods to include. Would that help? What I mean is in the previous design nonpropertys got the setter with no arguments only, and propertys got the setter with an argument only. With the new design both get both correct? Which means that we're adding superfluous methods here.
On 2017/02/23 at 00:23:08, bugsnash wrote: > On 2017/02/23 at 00:19:15, shend wrote: > > On 2017/02/23 at 00:13:34, bugsnash wrote: > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > File third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl (right): > > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl:1: {% import 'fields/base.tmpl' as base %} > > > This template is identical to the flag template. How do we determine which methods are to be excluded? > > > > Yes, I'll eventually be adding more methods to the keywords template (if not I'll just merge the two templates). I'm not sure what you mean by which methods are excluded. With this setup, you can't really "exclude" methods. It is possible to split the "base.decl_methods" macro into "decl_getter" and "decl_setter" etc. so you can cherry pick what methods to include. Would that help? > > What I mean is in the previous design nonpropertys got the setter with no arguments only, and propertys got the setter with an argument only. With the new design both get both correct? Which means that we're adding superfluous methods here. So 'keyword' and 'flag' are for properties and take arguments in their setter. 'monotonic_flag' (urgh) is for nonproperties and they don't take an argument.
On 2017/02/23 at 00:27:15, shend wrote: > On 2017/02/23 at 00:23:08, bugsnash wrote: > > On 2017/02/23 at 00:19:15, shend wrote: > > > On 2017/02/23 at 00:13:34, bugsnash wrote: > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > File third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl (right): > > > > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl:1: {% import 'fields/base.tmpl' as base %} > > > > This template is identical to the flag template. How do we determine which methods are to be excluded? > > > > > > Yes, I'll eventually be adding more methods to the keywords template (if not I'll just merge the two templates). I'm not sure what you mean by which methods are excluded. With this setup, you can't really "exclude" methods. It is possible to split the "base.decl_methods" macro into "decl_getter" and "decl_setter" etc. so you can cherry pick what methods to include. Would that help? > > > > What I mean is in the previous design nonpropertys got the setter with no arguments only, and propertys got the setter with an argument only. With the new design both get both correct? Which means that we're adding superfluous methods here. > > So 'keyword' and 'flag' are for properties and take arguments in their setter. 'monotonic_flag' (urgh) is for nonproperties and they don't take an argument. Right. So with this patch the 'keyword' and 'flag' properties will get both the setter with an argument and the setter with no argument right? And the the nonproperties will get both setters too?
On 2017/02/23 at 00:36:27, bugsnash wrote: > On 2017/02/23 at 00:27:15, shend wrote: > > On 2017/02/23 at 00:23:08, bugsnash wrote: > > > On 2017/02/23 at 00:19:15, shend wrote: > > > > On 2017/02/23 at 00:13:34, bugsnash wrote: > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > > File third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl (right): > > > > > > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > > third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl:1: {% import 'fields/base.tmpl' as base %} > > > > > This template is identical to the flag template. How do we determine which methods are to be excluded? > > > > > > > > Yes, I'll eventually be adding more methods to the keywords template (if not I'll just merge the two templates). I'm not sure what you mean by which methods are excluded. With this setup, you can't really "exclude" methods. It is possible to split the "base.decl_methods" macro into "decl_getter" and "decl_setter" etc. so you can cherry pick what methods to include. Would that help? > > > > > > What I mean is in the previous design nonpropertys got the setter with no arguments only, and propertys got the setter with an argument only. With the new design both get both correct? Which means that we're adding superfluous methods here. > > > > So 'keyword' and 'flag' are for properties and take arguments in their setter. 'monotonic_flag' (urgh) is for nonproperties and they don't take an argument. > > Right. So with this patch the 'keyword' and 'flag' properties will get both the setter with an argument and the setter with no argument right? And the the nonproperties will get both setters too? No, all the templates have exactly one setter. 'keyword' should get exactly one setter that takes an argument. 'monotonic_flag' should get exactly one setter with no arguments. 'flag' is exactly the same as 'keyword' (for now).
On 2017/02/23 at 00:39:11, shend wrote: > On 2017/02/23 at 00:36:27, bugsnash wrote: > > On 2017/02/23 at 00:27:15, shend wrote: > > > On 2017/02/23 at 00:23:08, bugsnash wrote: > > > > On 2017/02/23 at 00:19:15, shend wrote: > > > > > On 2017/02/23 at 00:13:34, bugsnash wrote: > > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > > > File third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl (right): > > > > > > > > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > > > third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl:1: {% import 'fields/base.tmpl' as base %} > > > > > > This template is identical to the flag template. How do we determine which methods are to be excluded? > > > > > > > > > > Yes, I'll eventually be adding more methods to the keywords template (if not I'll just merge the two templates). I'm not sure what you mean by which methods are excluded. With this setup, you can't really "exclude" methods. It is possible to split the "base.decl_methods" macro into "decl_getter" and "decl_setter" etc. so you can cherry pick what methods to include. Would that help? > > > > > > > > What I mean is in the previous design nonpropertys got the setter with no arguments only, and propertys got the setter with an argument only. With the new design both get both correct? Which means that we're adding superfluous methods here. > > > > > > So 'keyword' and 'flag' are for properties and take arguments in their setter. 'monotonic_flag' (urgh) is for nonproperties and they don't take an argument. > > > > Right. So with this patch the 'keyword' and 'flag' properties will get both the setter with an argument and the setter with no argument right? And the the nonproperties will get both setters too? > > No, all the templates have exactly one setter. 'keyword' should get exactly one setter that takes an argument. 'monotonic_flag' should get exactly one setter with no arguments. 'flag' is exactly the same as 'keyword' (for now). Oh I see, ignore me. So keyword and flag properties do have identical methods currently, but you're planning in the future to have different methods for them. It does seem to leave the code in a state that doesn't make much sense to have separate but identical templates for them here. However if it's most likely that they will diverge then the alternative of merging them here then splitting them out later seems to create unnecessary work. Please add a comment to each of the identical templates stating that they are currently identical but they will diverge soon. or possibly a todo for adding extra unique methods. lgtm
On 2017/02/23 at 00:45:36, bugsnash wrote: > On 2017/02/23 at 00:39:11, shend wrote: > > On 2017/02/23 at 00:36:27, bugsnash wrote: > > > On 2017/02/23 at 00:27:15, shend wrote: > > > > On 2017/02/23 at 00:23:08, bugsnash wrote: > > > > > On 2017/02/23 at 00:19:15, shend wrote: > > > > > > On 2017/02/23 at 00:13:34, bugsnash wrote: > > > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > > > > File third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl (right): > > > > > > > > > > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > > > > third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl:1: {% import 'fields/base.tmpl' as base %} > > > > > > > This template is identical to the flag template. How do we determine which methods are to be excluded? > > > > > > > > > > > > Yes, I'll eventually be adding more methods to the keywords template (if not I'll just merge the two templates). I'm not sure what you mean by which methods are excluded. With this setup, you can't really "exclude" methods. It is possible to split the "base.decl_methods" macro into "decl_getter" and "decl_setter" etc. so you can cherry pick what methods to include. Would that help? > > > > > > > > > > What I mean is in the previous design nonpropertys got the setter with no arguments only, and propertys got the setter with an argument only. With the new design both get both correct? Which means that we're adding superfluous methods here. > > > > > > > > So 'keyword' and 'flag' are for properties and take arguments in their setter. 'monotonic_flag' (urgh) is for nonproperties and they don't take an argument. > > > > > > Right. So with this patch the 'keyword' and 'flag' properties will get both the setter with an argument and the setter with no argument right? And the the nonproperties will get both setters too? > > > > No, all the templates have exactly one setter. 'keyword' should get exactly one setter that takes an argument. 'monotonic_flag' should get exactly one setter with no arguments. 'flag' is exactly the same as 'keyword' (for now). > > Oh I see, ignore me. So keyword and flag properties do have identical methods currently, but you're planning in the future to have different methods for them. It does seem to leave the code in a state that doesn't make much sense to have separate but identical templates for them here. However if it's most likely that they will diverge then the alternative of merging them here then splitting them out later seems to create unnecessary work. Please add a comment to each of the identical templates stating that they are currently identical but they will diverge soon. or possibly a todo for adding extra unique methods. lgtm Cool, sorry for the confusion. Yes I agree. I'll either add a TODO or just add the extra methods in now.
On 2017/02/23 at 00:53:19, shend wrote: > On 2017/02/23 at 00:45:36, bugsnash wrote: > > On 2017/02/23 at 00:39:11, shend wrote: > > > On 2017/02/23 at 00:36:27, bugsnash wrote: > > > > On 2017/02/23 at 00:27:15, shend wrote: > > > > > On 2017/02/23 at 00:23:08, bugsnash wrote: > > > > > > On 2017/02/23 at 00:19:15, shend wrote: > > > > > > > On 2017/02/23 at 00:13:34, bugsnash wrote: > > > > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > > > > > File third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl (right): > > > > > > > > > > > > > > > > https://codereview.chromium.org/2693933003/diff/140001/third_party/WebKit/Sou... > > > > > > > > third_party/WebKit/Source/build/scripts/templates/fields/keyword.tmpl:1: {% import 'fields/base.tmpl' as base %} > > > > > > > > This template is identical to the flag template. How do we determine which methods are to be excluded? > > > > > > > > > > > > > > Yes, I'll eventually be adding more methods to the keywords template (if not I'll just merge the two templates). I'm not sure what you mean by which methods are excluded. With this setup, you can't really "exclude" methods. It is possible to split the "base.decl_methods" macro into "decl_getter" and "decl_setter" etc. so you can cherry pick what methods to include. Would that help? > > > > > > > > > > > > What I mean is in the previous design nonpropertys got the setter with no arguments only, and propertys got the setter with an argument only. With the new design both get both correct? Which means that we're adding superfluous methods here. > > > > > > > > > > So 'keyword' and 'flag' are for properties and take arguments in their setter. 'monotonic_flag' (urgh) is for nonproperties and they don't take an argument. > > > > > > > > Right. So with this patch the 'keyword' and 'flag' properties will get both the setter with an argument and the setter with no argument right? And the the nonproperties will get both setters too? > > > > > > No, all the templates have exactly one setter. 'keyword' should get exactly one setter that takes an argument. 'monotonic_flag' should get exactly one setter with no arguments. 'flag' is exactly the same as 'keyword' (for now). > > > > Oh I see, ignore me. So keyword and flag properties do have identical methods currently, but you're planning in the future to have different methods for them. It does seem to leave the code in a state that doesn't make much sense to have separate but identical templates for them here. However if it's most likely that they will diverge then the alternative of merging them here then splitting them out later seems to create unnecessary work. Please add a comment to each of the identical templates stating that they are currently identical but they will diverge soon. or possibly a todo for adding extra unique methods. lgtm > > Cool, sorry for the confusion. Yes I agree. I'll either add a TODO or just add the extra methods in now. I think a todo is more appropriate, keep the patches silo'd
Description was changed from ========== Move field-dependent template code from ComputedStyleBase to macros. When we're generating fields in ComputedStyleBase, there are cases where the generated code depends on the field template. For example, keyword fields may have different getters than platform type fields. Instead of doing if-else statements inside the template which makes it quite ugly, this patch moves that logic out into their own files as macros. Each file defines macros that specify how a field should be generated. This patch adds a 'keyword' template for enums, 'flag' template for bools, and 'monotonic_flag' for nonproperty flags that can't be set to false. This patch does not change behaviour. BUG=628043 ========== to ========== Move field-dependent template code from ComputedStyleBase to macros. When we're generating fields in ComputedStyleBase, there are cases where the generated code depends on the field template. For example, keyword fields may have different getters than platform type fields. Instead of doing if-else statements inside the template which makes it quite ugly, this patch moves that logic out into their own files as macros. Each file defines macros that specify how a field should be generated. This patch adds a 'keyword' template for enums, 'flag' template for bools, and 'monotonic_flag' for nonproperty flags that can't be set to false. Link to generated code: https://gist.github.com/anonymous/93f5d3907e3515d0b50adf0107f3000e Link to diff (see differences in 'initialUnique' and 'resetUnique'): https://www.diffchecker.com/mikllVbf BUG=628043 ==========
lgtm This seems good, but at first I thought you were generating C++ macros, lol. It's probably worth specifying that you mean jinja macros :p
Description was changed from ========== Move field-dependent template code from ComputedStyleBase to macros. When we're generating fields in ComputedStyleBase, there are cases where the generated code depends on the field template. For example, keyword fields may have different getters than platform type fields. Instead of doing if-else statements inside the template which makes it quite ugly, this patch moves that logic out into their own files as macros. Each file defines macros that specify how a field should be generated. This patch adds a 'keyword' template for enums, 'flag' template for bools, and 'monotonic_flag' for nonproperty flags that can't be set to false. Link to generated code: https://gist.github.com/anonymous/93f5d3907e3515d0b50adf0107f3000e Link to diff (see differences in 'initialUnique' and 'resetUnique'): https://www.diffchecker.com/mikllVbf BUG=628043 ========== to ========== Move field-dependent code in ComputedStyleBase to Jinja macros. When we're generating fields in ComputedStyleBase, there are cases where the generated code depends on the field template. For example, keyword fields may have different getters than platform type fields. Instead of doing if-else statements inside the template which makes it quite ugly, this patch moves that logic out into their own files as Jinja macros. Each file defines Jinja macros that specify how a field should be generated. This patch adds a 'keyword' template for enums, 'flag' template for bools, and 'monotonic_flag' for nonproperty flags that can't be set to false. Link to generated code: https://gist.github.com/anonymous/93f5d3907e3515d0b50adf0107f3000e Link to diff (see differences in 'initialUnique' and 'resetUnique'): https://www.diffchecker.com/mikllVbf BUG=628043 ==========
The CQ bit was checked by shend@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by shend@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by shend@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from bugsnash@chromium.org, meade@chromium.org Link to the patchset: https://codereview.chromium.org/2693933003/#ps180001 (title: "Rebase")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 180001, "attempt_start_ts": 1489167633213050, "parent_rev": "b579d0a779919583b7f77793d2f47a23eab9c1c0", "commit_rev": "6ce2feb35c970fe7d9557c851c016c6d6c8b1d39"}
Message was sent while issue was closed.
Description was changed from ========== Move field-dependent code in ComputedStyleBase to Jinja macros. When we're generating fields in ComputedStyleBase, there are cases where the generated code depends on the field template. For example, keyword fields may have different getters than platform type fields. Instead of doing if-else statements inside the template which makes it quite ugly, this patch moves that logic out into their own files as Jinja macros. Each file defines Jinja macros that specify how a field should be generated. This patch adds a 'keyword' template for enums, 'flag' template for bools, and 'monotonic_flag' for nonproperty flags that can't be set to false. Link to generated code: https://gist.github.com/anonymous/93f5d3907e3515d0b50adf0107f3000e Link to diff (see differences in 'initialUnique' and 'resetUnique'): https://www.diffchecker.com/mikllVbf BUG=628043 ========== to ========== Move field-dependent code in ComputedStyleBase to Jinja macros. When we're generating fields in ComputedStyleBase, there are cases where the generated code depends on the field template. For example, keyword fields may have different getters than platform type fields. Instead of doing if-else statements inside the template which makes it quite ugly, this patch moves that logic out into their own files as Jinja macros. Each file defines Jinja macros that specify how a field should be generated. This patch adds a 'keyword' template for enums, 'flag' template for bools, and 'monotonic_flag' for nonproperty flags that can't be set to false. Link to generated code: https://gist.github.com/anonymous/93f5d3907e3515d0b50adf0107f3000e Link to diff (see differences in 'initialUnique' and 'resetUnique'): https://www.diffchecker.com/mikllVbf BUG=628043 Review-Url: https://codereview.chromium.org/2693933003 Cr-Commit-Position: refs/heads/master@{#456095} Committed: https://chromium.googlesource.com/chromium/src/+/6ce2feb35c970fe7d9557c851c01... ==========
Message was sent while issue was closed.
Committed patchset #10 (id:180001) as https://chromium.googlesource.com/chromium/src/+/6ce2feb35c970fe7d9557c851c01... |