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

Issue 758523002: Store :last/first-child state as restyle flags. (Closed)

Created:
6 years ago by rune
Modified:
6 years ago
Reviewers:
esprehn
CC:
darktears, apavlov+blink_chromium.org, blink-reviews, blink-reviews-animation_chromium.org, blink-reviews-css, blink-reviews-dom_chromium.org, blink-reviews-rendering, dglazkov+blink, dstockwell, eae+blinkwatch, ed+blinkwatch_opera.com, Eric Willigers, jchaffraix+rendering, leviw+renderwatch, Mike Lawther (Google), pdr+renderingwatchlist_chromium.org, rjwright, rwlbuis, shans, sof, Steve Block, Timothy Loh, zoltan1
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

Store :last/first-child state as restyle flags. firstChildState and lastChildState were set to true on RenderStyle if we had tried to match :first-child or :last-child on the element for which we were constructing the RenderStyle. But also, when trying to match :last-child on siblings or ascendants of the element, we set this flag on their RenderStyle objects respectively. That was problematic for a number of reasons. First, the state is used to check if an element needs a style recalc when nodes are added or removed, and that recalc is also necessary for if you have :last-child { display: none } in which case you have no RenderStyle. Second, the flag was reset as part of recalculating style for a RenderStyle whose descendants depended on its :last-child state. That flag would not be set again if the descendants themselves didn't need a recalc. Last, the flag inconsistency caused RenderStyle operator== to incorrectly return false, causing an assert in the animations code. This CL converts these RenderStyle state flags to DynamicRestyleFlags on Element instead. That means they will give more false positives about the need to recalculate for last-child/first-child mutations since they will not be reset that often. They will be cleared along with the other restyle flags when the element is removed from the tree. Since they will not be reset on style recalc, they will also be unconditionally set when trying to match the selector, not only when it matches. BUG=435481, 100559, 435534 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=186043

Patch Set 1 #

Patch Set 2 : Null-ptr checks and bug-fixes #

Total comments: 1

Patch Set 3 : Added :only-child test #

Patch Set 4 : Fixed assert #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+154 lines, -32 lines) Patch
A LayoutTests/fast/animation/last-child-assert.html View 1 chunk +11 lines, -0 lines 0 comments Download
A LayoutTests/fast/animation/last-child-assert-expected.html View 1 chunk +3 lines, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/first-child-descendant.html View 1 chunk +23 lines, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/first-child-descendant-expected.txt View 1 chunk +10 lines, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/first-child-display-none.html View 1 chunk +18 lines, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/first-child-display-none-expected.txt View 1 chunk +1 line, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/last-child-descendant.html View 1 chunk +23 lines, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/last-child-descendant-expected.txt View 1 chunk +11 lines, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/last-child-display-none.html View 1 chunk +18 lines, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/last-child-display-none-expected.txt View 1 chunk +3 lines, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/only-child.html View 1 2 1 chunk +12 lines, -0 lines 0 comments Download
A LayoutTests/fast/dynamic/only-child-expected.html View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M Source/core/css/SelectorChecker.cpp View 1 3 chunks +4 lines, -11 lines 0 comments Download
M Source/core/dom/ContainerNode.h View 2 chunks +9 lines, -1 line 0 comments Download
M Source/core/dom/ContainerNode.cpp View 1 2 3 2 chunks +6 lines, -10 lines 2 comments Download
M Source/core/rendering/style/RenderStyle.h View 4 chunks +0 lines, -10 lines 0 comments Download

Messages

Total messages: 16 (4 generated)
rune
6 years ago (2014-11-24 15:27:13 UTC) #2
esprehn
https://codereview.chromium.org/758523002/diff/20001/Source/core/css/SelectorChecker.cpp File Source/core/css/SelectorChecker.cpp (right): https://codereview.chromium.org/758523002/diff/20001/Source/core/css/SelectorChecker.cpp#newcode665 Source/core/css/SelectorChecker.cpp:665: element.setAffectedByLastChildRules(); Why not check firstChild and onlyChild like before?
6 years ago (2014-11-24 18:46:05 UTC) #3
rune
On 2014/11/24 18:46:05, esprehn wrote: > https://codereview.chromium.org/758523002/diff/20001/Source/core/css/SelectorChecker.cpp > File Source/core/css/SelectorChecker.cpp (right): > > https://codereview.chromium.org/758523002/diff/20001/Source/core/css/SelectorChecker.cpp#newcode665 > ...
6 years ago (2014-11-25 10:11:39 UTC) #4
rune
On 2014/11/25 10:11:39, rune wrote: > Otherwise, this test will fail (I'll add this test): ...
6 years ago (2014-11-25 10:30:10 UTC) #5
esprehn
lgtm
6 years ago (2014-11-26 01:00:32 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/758523002/40001
6 years ago (2014-11-26 07:28:45 UTC) #8
commit-bot: I haz the power
Try jobs failed on following builders: linux_blink_rel on tryserver.blink (http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/35642)
6 years ago (2014-11-26 08:46:07 UTC) #10
rune
ASSERTION FAILED: changeType == SiblingElementInserted
6 years ago (2014-11-26 08:50:41 UTC) #11
rune
PTAL https://codereview.chromium.org/758523002/diff/60001/Source/core/dom/ContainerNode.cpp File Source/core/dom/ContainerNode.cpp (right): https://codereview.chromium.org/758523002/diff/60001/Source/core/dom/ContainerNode.cpp#newcode1299 Source/core/dom/ContainerNode.cpp:1299: elementAfterChange->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::SiblingSelector)); Since the flag is not cleared ...
6 years ago (2014-11-26 15:14:05 UTC) #12
esprehn
lgtm, seems reasonable. Eventually we should probably teach the style invalidator how to invalidate sibling ...
6 years ago (2014-11-26 17:07:47 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/758523002/60001
6 years ago (2014-11-26 17:19:57 UTC) #15
commit-bot: I haz the power
6 years ago (2014-11-26 18:26:00 UTC) #16
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as
https://src.chromium.org/viewvc/blink?view=rev&revision=186043

Powered by Google App Engine
This is Rietveld 408576698