The ComputedStyle object provides an interface between style and the rest of the Blink engine. Right now it is a confusing mess of logic and data, with methods organized in an way that made sense 10 years ago when properties were few and WebKit supported multiple browsers but is no longer useful for developers. The current design makes it hard to reason about improvements to ComputedStyle and makes it easy to make mistakes since code and logic duplication is high. This is frustrating for developers and slows down innovation to our engine.
Cleaning up ComputedStyle involves a few ideas:
1. Renaming methods and fields to conform to Blink's style guidelines
2. Moving towards a property-centric design, with getters/setters sorted and organised by property
3. Moving as much property logic out of ComputedStyle as possible, leaving just a highly-optimized container
4. Finding a way to make ComputedStyle generic and generating field storage at compile or runtime
5. Thinking of ways to optimize ComputedStyle for memory and inherited changes, e.g.:
(a) Packing fields better
(b) Data-driven field layout in memory (less pointer hops for more frequently accessed data, even a live cache)
(c) Re-thinking style sharing to share pieces of ComputedStyle
(d) Rather than storing the whole style, storing only diffs from a parent/ancestor element
(e) Storing pointers to expressions as well as resolved values
(f) Storing pointers to where a property was inherited from
(g) etc.
As a parallel goal, we should also aim to make ComputedStyle const after style resolution.
Other than 5, these should be mostly mechanical changes that make it easier to analyze and reason about ComputedStyle and pave the way to more complex optimizations and improvements.
The ComputedStyle object provides an interface between style and the rest of the Blink engine. Right now it is a confusing mess of logic and data, with methods organized in an way that made sense 10 years ago when properties were few and WebKit supported multiple browsers but is no longer useful for developers. The current design makes it hard to reason about improvements to ComputedStyle and makes it easy to make mistakes since code and logic duplication is high. This is frustrating for developers and slows down innovation to our engine.
Cleaning up ComputedStyle involves a few ideas:
1. Renaming methods and fields to conform to Blink's style guidelines
2. Moving towards a property-centric design, with getters/setters sorted and organised by property
3. Moving as much property logic out of ComputedStyle as possible, leaving just a highly-optimized container
4. Finding a way to make ComputedStyle generic and generating field storage at compile or runtime
5. Thinking of ways to optimize ComputedStyle for memory and inherited changes, e.g.:
(a) Packing fields better
(b) Data-driven field layout in memory (less pointer hops for more frequently accessed data, even a live cache)
(c) Re-thinking style sharing to share pieces of ComputedStyle
(d) Rather than storing the whole style, storing only diffs from a parent/ancestor element
(e) Storing pointers to expressions as well as resolved values
(f) Storing pointers to where a property was inherited from
(g) Store the layout-dependent properties (for example) separately to the other properties
(h) etc.
As a parallel goal, we should also aim to make ComputedStyle const after style resolution.
Other than 5, these should be mostly mechanical changes that make it easier to analyze and reason about ComputedStyle and pave the way to more complex optimizations and improvements.
The ComputedStyle object provides an interface between style and the rest of the Blink engine. Right now it is a confusing mess of logic and data, with methods organized in an way that made sense 10 years ago when properties were few and WebKit supported multiple browsers but is no longer useful for developers. The current design makes it hard to reason about improvements to ComputedStyle and makes it easy to make mistakes since code and logic duplication is high. This is frustrating for developers and slows down innovation to our engine.
Cleaning up ComputedStyle involves a few ideas:
1. Renaming methods and fields to conform to Blink's style guidelines
2. Moving towards a property-centric design, with getters/setters sorted and organised by property
3. Moving as much property logic out of ComputedStyle as possible, leaving just a highly-optimized container
4. Finding a way to make ComputedStyle generic and generating field storage at compile or runtime
5. Thinking of ways to optimize ComputedStyle for memory and inherited changes, e.g.:
(a) Packing fields better
(b) Data-driven field layout in memory (less pointer hops for more frequently accessed data, even a live cache)
(c) Re-thinking style sharing to share pieces of ComputedStyle
(d) Rather than storing the whole style, storing only diffs from a parent/ancestor element
(e) Storing pointers to expressions as well as resolved values
(f) Storing pointers to where a property was inherited from
(g) Store the layout-dependent properties (for example) separately to the other properties
(h) etc.
As a parallel goal, we should also aim to make ComputedStyle const after style resolution.
Other than 5, these should be mostly mechanical changes that make it easier to analyze and reason about ComputedStyle and pave the way to more complex optimizations and improvements.
Design doc: https://docs.google.com/document/u/1/d/1sWf_kCtVSokx8oDJZwTrUk2JNqrgTZDV0Z-jsy6tWxg/edit#
The ComputedStyle object provides an interface between style and the rest of the Blink engine. Right now it is a confusing mess of logic and data, with methods organized in an way that made sense 10 years ago when properties were few and WebKit supported multiple browsers but is no longer useful for developers. The current design makes it hard to reason about improvements to ComputedStyle and makes it easy to make mistakes since code and logic duplication is high. This is frustrating for developers and slows down innovation to our engine.
Cleaning up ComputedStyle involves a few ideas:
1. Renaming methods and fields to conform to Blink's style guidelines
2. Moving towards a property-centric design, with getters/setters sorted and organised by property
3. Moving as much property logic out of ComputedStyle as possible, leaving just a highly-optimized container
4. Finding a way to make ComputedStyle generic and generating field storage at compile or runtime
5. Thinking of ways to optimize ComputedStyle for memory and inherited changes, e.g.:
(a) Packing fields better
(b) Data-driven field layout in memory (less pointer hops for more frequently accessed data, even a live cache)
(c) Re-thinking style sharing to share pieces of ComputedStyle
(d) Rather than storing the whole style, storing only diffs from a parent/ancestor element
(e) Storing pointers to expressions as well as resolved values
(f) Storing pointers to where a property was inherited from
(g) Store the layout-dependent properties (for example) separately to the other properties
(h) etc.
As a parallel goal, we should also aim to make ComputedStyle const after style resolution.
Other than 5, these should be mostly mechanical changes that make it easier to analyze and reason about ComputedStyle and pave the way to more complex optimizations and improvements.
Design doc: https://docs.google.com/document/d/1LcH2GAI_0_c4MtBUjYqcokQASXne-DFDy4fZ3Apy25I/edit#
More info about the reasons for the above revert:
Broken build:
https://build.chromium.org/p/chromium.webkit/builders/WebKit%20Mac%20Builder/builds/210181
Relevant log:
[456/4958] ACTION //third_party/WebKit/Source/core:make_core_generated_computed_style_base(//build/toolchain/mac:clang_x64)
FAILED: gen/blink/core/ComputedStyleBase.h gen/blink/core/ComputedStyleBase.cpp gen/blink/core/ComputedStyleBaseConstants.h
python ../../third_party/WebKit/Source/build/scripts/make_computed_style_base.py ../../third_party/WebKit/Source/core/css/CSSProperties.json5 ../../third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5 ../../third_party/WebKit/Source/core/css/ComputedStyleDiffFunctions.json5 --output_dir gen/blink/core --gperf gperf
Traceback (most recent call last):
File "../../third_party/WebKit/Source/build/scripts/make_computed_style_base.py", line 545, in <module>
json5_generator.Maker(ComputedStyleBaseWriter).main()
File "/b/c/b/mac_layout/src/third_party/WebKit/Source/build/scripts/json5_generator.py", line 248, in main
writer = self._writer_class(args.files)
File "../../third_party/WebKit/Source/build/scripts/make_computed_style_base.py", line 508, in __init__
).name_dictionaries, self._root_group)
File "../../third_party/WebKit/Source/build/scripts/make_computed_style_base.py", line 260, in _create_diff_groups_map
"Please check that there's an entry for '" + name + "' in CSSProperties.json5 or ComputedStyleExtraFields.json5")
AssertionError: The field 'ColumnRule' isn't a defined field on ComputedStyle. Please check that there's an entry for 'ColumnRule' in CSSProperties.json5 or ComputedStyleExtraFields.json5