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

Issue 350333003: Cascade declared property values instead of applying values on top of each other (Closed)

Created:
6 years, 6 months ago by Timothy Loh
Modified:
6 years, 3 months ago
CC:
darktears, apavlov+blink_chromium.org, blink-reviews, blink-reviews-css, dglazkov+blink, ed+blinkwatch_opera.com, rwlbuis, rune+blink
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

Cascade declared property values instead of applying values on top of each other Currently, the StyleResolver builds the style for an element by calling StyleBuilder::applyProperty in the appropriate order for all the matched property declarations. This is inefficient in that for elements with complex styling, many of these declarations will be overridden by other declarations, so we will end up doing many unneeded conversions of CSSValues. This patch makes us cascade declared property values before applying, so that we generally only end up applying each property at most once (-webkit-appearance and animations break this rule). The existence of vendor-prefixed properties complicate this change somewhat. It's generally accepted that specifying a property and a vendor-prefixed variant will have the latter one take effect. Thus we map these to the same property, so they can properly cascade, and disallow calling into the StyleBuilder with these aliased properties. To handle this for the various non-standard direction aware properties, we resolve the values of direction and writing-mode (now super-high priority) before cascading. Note that -webkit-perspective allows more values that perspective (in particular, numbers are allowed), although they now use the same handler. The test transforms/perspective-parsing.html ensures that perspective considers values that are allowed for -webkit-perspective as invalid. This patch is similar in nature to similar work done in WebKit by akling, https://bugs.webkit.org/show_bug.cgi?id=125213. The implementation is different here in lots of little ways, although I've copied the function elementTypeHasAppearanceFromUAStyle to avoid doing work to support -webkit-appearance in the common case. BUG=399497

Patch Set 1 #

Patch Set 2 : tests pass; needs clean up and whatnot #

Patch Set 3 : ready for review! #

Patch Set 4 : rebase and small clean ups #

Patch Set 5 : #

Total comments: 4

Patch Set 6 : rebase #

Patch Set 7 : address some comments #

Patch Set 8 : move functions around :| #

Total comments: 16

Patch Set 9 : rebase #

Patch Set 10 : address comments #

Patch Set 11 : rebase #

Patch Set 12 : rebase #

Total comments: 4

Patch Set 13 : rebase #

Patch Set 14 : leave property whitelists on styleresolver and dont return CSSValue*& #

Patch Set 15 : minor optimisation #

Patch Set 16 : rebase #

Patch Set 17 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+425 lines, -355 lines) Patch
M Source/build/scripts/make_style_builder.py View 1 2 3 2 chunks +1 line, -4 lines 0 comments Download
M Source/build/scripts/templates/StyleBuilder.cpp.tmpl View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +4 lines, -15 lines 0 comments Download
M Source/core/core.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +2 lines, -0 lines 0 comments Download
M Source/core/css/CSSProperties.in View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 8 chunks +1 line, -41 lines 0 comments Download
M Source/core/css/CSSProperty.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +5 lines, -6 lines 0 comments Download
M Source/core/css/CSSPropertyNames.in View 1 2 3 4 5 6 7 8 9 10 5 chunks +14 lines, -10 lines 0 comments Download
A Source/core/css/resolver/CascadedValues.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +53 lines, -0 lines 0 comments Download
A Source/core/css/resolver/CascadedValues.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +256 lines, -0 lines 0 comments Download
M Source/core/css/resolver/StyleBuilderCustom.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 4 chunks +7 lines, -57 lines 0 comments Download
M Source/core/css/resolver/StyleResolver.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +8 lines, -9 lines 0 comments Download
M Source/core/css/resolver/StyleResolver.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 13 chunks +73 lines, -200 lines 0 comments Download
M Source/core/css/resolver/StyleResolverState.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 4 chunks +0 lines, -10 lines 0 comments Download
M Source/core/css/resolver/StyleResolverState.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +0 lines, -2 lines 0 comments Download
M Source/core/rendering/style/FillLayer.cpp View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 16 (0 generated)
Timothy Loh
Hey guys, This change isn't quite done yet but I'd like to get some quick ...
6 years, 6 months ago (2014-06-26 02:01:51 UTC) #1
esprehn
On 2014/06/26 at 02:01:51, timloh wrote: > Hey guys, > > This change isn't quite ...
6 years, 6 months ago (2014-06-26 02:09:08 UTC) #2
Timothy Loh
This is ready for review now. A subsequent (not yet ready) patch (https://codereview.chromium.org/361173002/) will somewhat ...
6 years, 5 months ago (2014-07-02 07:50:47 UTC) #3
Timothy Loh
PTAL
6 years, 5 months ago (2014-07-17 04:48:26 UTC) #4
andersr
Nice. I wonder if we can be more clever with our style application as a ...
6 years, 5 months ago (2014-07-17 12:15:38 UTC) #5
Timothy Loh
https://codereview.chromium.org/350333003/diff/210001/Source/core/css/resolver/CascadedValues.cpp File Source/core/css/resolver/CascadedValues.cpp (right): https://codereview.chromium.org/350333003/diff/210001/Source/core/css/resolver/CascadedValues.cpp#newcode259 Source/core/css/resolver/CascadedValues.cpp:259: for (size_t i = 0; i < matchResult.matchedProperties.size(); ++i) ...
6 years, 5 months ago (2014-07-21 06:06:00 UTC) #6
Timothy Loh
On 2014/07/17 12:15:38, andersr wrote: > Nice. I wonder if we can be more clever ...
6 years, 5 months ago (2014-07-21 06:30:32 UTC) #7
esprehn
This patch is pretty big, can we break it up? https://codereview.chromium.org/350333003/diff/270001/Source/core/css/resolver/CascadedValues.cpp File Source/core/css/resolver/CascadedValues.cpp (right): https://codereview.chromium.org/350333003/diff/270001/Source/core/css/resolver/CascadedValues.cpp#newcode18 ...
6 years, 5 months ago (2014-07-21 18:50:35 UTC) #8
Timothy Loh
I couldn't think of any reasonable way to break this up. The part of the ...
6 years, 5 months ago (2014-07-22 14:32:48 UTC) #9
Timothy Loh
PTAL, thanks!
6 years, 4 months ago (2014-07-28 15:08:23 UTC) #10
esprehn
Can we really not do the code moves in one patch, and the refactoring into ...
6 years, 4 months ago (2014-07-28 17:38:35 UTC) #11
Timothy Loh
https://codereview.chromium.org/350333003/diff/370001/Source/core/css/resolver/CascadedValues.cpp File Source/core/css/resolver/CascadedValues.cpp (right): https://codereview.chromium.org/350333003/diff/370001/Source/core/css/resolver/CascadedValues.cpp#newcode303 Source/core/css/resolver/CascadedValues.cpp:303: // problems with e.g. foo:first-letter { all: inherit; } ...
6 years, 4 months ago (2014-07-29 08:32:15 UTC) #12
Timothy Loh
On 2014/07/28 17:38:35, esprehn wrote: > Can we really not do the code moves in ...
6 years, 4 months ago (2014-07-29 08:46:30 UTC) #13
Timothy Loh
On 2014/07/29 08:46:30, Timothy Loh wrote: > On 2014/07/28 17:38:35, esprehn wrote: > > Can ...
6 years, 4 months ago (2014-07-30 10:35:08 UTC) #14
Timothy Loh
PTAL One more optimisation I came up with here is that if we have a ...
6 years, 4 months ago (2014-08-05 02:19:39 UTC) #15
Timothy Loh
6 years, 3 months ago (2014-08-26 00:58:27 UTC) #16
On 2014/08/05 02:19:39, Timothy Loh wrote:
> PTAL
> 
> One more optimisation I came up with here is that if we have a cascaded value
of
> inherit for an inherited property or initial for a non-inherited property then
> we should be able to skip applying the property entirely. This should be
fairly
> common when specifying shorthands (e.g. "background: black" sets nine
properties
> to initial).
> 
> I can't do this yet due to the re-application for -webkit-appearance, although
> it shouldn't be too much extra work to make this optimisation possible.

Going to close this for now; I've made a whole heap of changes which I need to
rebase over and there's a couple of changes I still want to do before revisiting
this.

Powered by Google App Engine
This is Rietveld 408576698