Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
| diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
| index d837619411d9c3ac0a08528f86939465039dc0f2..038739b0b277d606c8d450e5e7fbf40d154c1be9 100644 |
| --- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
| +++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
| @@ -579,8 +579,11 @@ PassRefPtr<ComputedStyle> StyleResolver::styleForDocument(Document& document) { |
| void StyleResolver::adjustComputedStyle(StyleResolverState& state, |
| Element* element) { |
| + DCHECK(state.layoutParentStyle()); |
| + DCHECK(state.parentStyle()); |
| StyleAdjuster::adjustComputedStyle(state.mutableStyleRef(), |
| - *state.parentStyle(), element); |
| + *state.parentStyle(), |
| + *state.layoutParentStyle(), element); |
| } |
| // Start loading resources referenced by this style. |
| @@ -622,6 +625,7 @@ static void updateBaseComputedStyle(StyleResolverState& state, |
| PassRefPtr<ComputedStyle> StyleResolver::styleForElement( |
| Element* element, |
| const ComputedStyle* defaultParent, |
| + const ComputedStyle* defaultLayoutParent, |
| StyleSharingBehavior sharingBehavior, |
| RuleMatchingBehavior matchingBehavior) { |
| DCHECK(document().frame()); |
| @@ -658,15 +662,18 @@ PassRefPtr<ComputedStyle> StyleResolver::styleForElement( |
| return sharedStyle.release(); |
| } |
| - StyleResolverState state(document(), elementContext, defaultParent); |
| + StyleResolverState state(document(), elementContext, defaultParent, |
| + defaultLayoutParent); |
| const ComputedStyle* baseComputedStyle = |
| calculateBaseComputedStyle(state, element); |
| if (baseComputedStyle) { |
| state.setStyle(ComputedStyle::clone(*baseComputedStyle)); |
| - if (!state.parentStyle()) |
| + if (!state.parentStyle()) { |
| state.setParentStyle(initialStyleForElement()); |
| + state.setLayoutParentStyle(state.parentStyle()); |
| + } |
| } else { |
| if (state.parentStyle()) { |
| RefPtr<ComputedStyle> style = ComputedStyle::create(); |
| @@ -678,6 +685,7 @@ PassRefPtr<ComputedStyle> StyleResolver::styleForElement( |
| } else { |
| state.setStyle(initialStyleForElement()); |
| state.setParentStyle(ComputedStyle::clone(*state.style())); |
| + state.setLayoutParentStyle(state.parentStyle()); |
| } |
| } |
| @@ -792,7 +800,8 @@ PassRefPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot( |
| const CSSValue* value) { |
| // TODO(alancutter): Avoid creating a StyleResolverState just to apply a |
| // single value on a ComputedStyle. |
| - StyleResolverState state(element.document(), &element, parentStyle); |
| + StyleResolverState state(element.document(), &element, parentStyle, |
| + parentStyle); |
|
rune
2017/01/27 13:09:23
Is it correct to use parentStyle both places here?
emilio
2017/01/27 22:13:15
We only use it to apply a given property as far as
rune
2017/02/06 22:40:43
Right, these are for compositor animations which d
|
| state.setStyle(ComputedStyle::clone(baseStyle)); |
| if (value) { |
| StyleBuilder::applyProperty(property, state, *value); |
| @@ -840,7 +849,7 @@ PseudoElement* StyleResolver::createPseudoElementIfNeeded(Element& parent, |
| return createPseudoElement(&parent, pseudoId); |
| } |
| - StyleResolverState state(document(), &parent, parentStyle); |
| + StyleResolverState state(document(), &parent, parentStyle, parentStyle); |
| if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
| return nullptr; |
| RefPtr<ComputedStyle> style = state.takeStyle(); |
| @@ -941,12 +950,14 @@ bool StyleResolver::pseudoStyleForElementInternal( |
| PassRefPtr<ComputedStyle> StyleResolver::pseudoStyleForElement( |
| Element* element, |
| const PseudoStyleRequest& pseudoStyleRequest, |
| - const ComputedStyle* parentStyle) { |
| + const ComputedStyle* parentStyle, |
| + const ComputedStyle* parentLayoutObjectStyle) { |
| DCHECK(parentStyle); |
| if (!element) |
| return nullptr; |
| - StyleResolverState state(document(), element, parentStyle); |
| + StyleResolverState state(document(), element, parentStyle, |
| + parentLayoutObjectStyle); |
| if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle, |
| state)) { |
| if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) |
| @@ -1912,7 +1923,7 @@ void StyleResolver::computeFont(ComputedStyle* style, |
| }; |
| // TODO(timloh): This is weird, the style is being used as its own parent |
| - StyleResolverState state(document(), nullptr, style); |
| + StyleResolverState state(document(), nullptr, style, style); |
| state.setStyle(style); |
| for (CSSPropertyID property : properties) { |