Commit a0f502e8 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Reorder code LayoutSVG* StyleDidChange() implementation

This moves all code that has direct dependencies on a Parent() being
available to the end of the functions and adds a common early-out.

Calls to the parent class' StyleDidChange() is moved first.

Bug: 1028061, 1028063
Change-Id: Ibd0b9d710128eff6383d3b48223bf838a553bacd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2509751
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822657}
parent 261617fb
...@@ -118,6 +118,8 @@ bool LayoutSVGBlock::UpdateTransformAfterLayout(bool bounds_changed) { ...@@ -118,6 +118,8 @@ bool LayoutSVGBlock::UpdateTransformAfterLayout(bool bounds_changed) {
void LayoutSVGBlock::StyleDidChange(StyleDifference diff, void LayoutSVGBlock::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) { const ComputedStyle* old_style) {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutBlock::StyleDidChange(diff, old_style);
transform_uses_reference_box_ = transform_uses_reference_box_ =
TransformHelper::DependsOnReferenceBox(StyleRef()); TransformHelper::DependsOnReferenceBox(StyleRef());
...@@ -127,19 +129,19 @@ void LayoutSVGBlock::StyleDidChange(StyleDifference diff, ...@@ -127,19 +129,19 @@ void LayoutSVGBlock::StyleDidChange(StyleDifference diff,
SetNeedsTransformUpdate(); SetNeedsTransformUpdate();
} }
if (diff.BlendModeChanged() && Parent()) { SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
if (!Parent())
return;
if (diff.BlendModeChanged()) {
DCHECK(IsBlendingAllowed()); DCHECK(IsBlendingAllowed());
Parent()->DescendantIsolationRequirementsChanged( Parent()->DescendantIsolationRequirementsChanged(
StyleRef().HasBlendMode() ? kDescendantIsolationRequired StyleRef().HasBlendMode() ? kDescendantIsolationRequired
: kDescendantIsolationNeedsUpdate); : kDescendantIsolationNeedsUpdate);
} }
if (diff.CompositingReasonsChanged()) if (diff.CompositingReasonsChanged())
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this); SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
if (diff.HasDifference()) {
LayoutBlock::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
if (diff.HasDifference() && Parent()) {
SVGResourcesCache::UpdateResources(*this); SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff); LayoutSVGResourceContainer::StyleDidChange(*this, diff);
} }
......
...@@ -126,17 +126,20 @@ void LayoutSVGInline::WillBeDestroyed() { ...@@ -126,17 +126,20 @@ void LayoutSVGInline::WillBeDestroyed() {
void LayoutSVGInline::StyleDidChange(StyleDifference diff, void LayoutSVGInline::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) { const ComputedStyle* old_style) {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutInline::StyleDidChange(diff, old_style);
if (diff.NeedsFullLayout()) if (diff.NeedsFullLayout())
SetNeedsBoundariesUpdate(); SetNeedsBoundariesUpdate();
if (diff.CompositingReasonsChanged())
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
LayoutInline::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(To<SVGElement>(*GetNode()), old_style, SVGResources::UpdateClipPathFilterMask(To<SVGElement>(*GetNode()), old_style,
StyleRef()); StyleRef());
SVGResources::UpdatePaints(To<SVGElement>(*GetNode()), old_style, StyleRef()); SVGResources::UpdatePaints(To<SVGElement>(*GetNode()), old_style, StyleRef());
if (diff.HasDifference() && Parent()) {
if (!Parent())
return;
if (diff.CompositingReasonsChanged())
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
if (diff.HasDifference()) {
SVGResourcesCache::UpdateResources(*this); SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff); LayoutSVGResourceContainer::StyleDidChange(*this, diff);
} }
......
...@@ -139,25 +139,27 @@ bool LayoutSVGModelObject::CheckForImplicitTransformChange( ...@@ -139,25 +139,27 @@ bool LayoutSVGModelObject::CheckForImplicitTransformChange(
void LayoutSVGModelObject::StyleDidChange(StyleDifference diff, void LayoutSVGModelObject::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) { const ComputedStyle* old_style) {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutObject::StyleDidChange(diff, old_style);
if (diff.NeedsFullLayout()) { if (diff.NeedsFullLayout()) {
SetNeedsBoundariesUpdate(); SetNeedsBoundariesUpdate();
if (diff.TransformChanged()) if (diff.TransformChanged())
SetNeedsTransformUpdate(); SetNeedsTransformUpdate();
} }
if (diff.BlendModeChanged() && Parent() && !IsSVGHiddenContainer()) { SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
if (!Parent())
return;
if (diff.BlendModeChanged() && !IsSVGHiddenContainer()) {
DCHECK(IsBlendingAllowed()); DCHECK(IsBlendingAllowed());
Parent()->DescendantIsolationRequirementsChanged( Parent()->DescendantIsolationRequirementsChanged(
StyleRef().HasBlendMode() ? kDescendantIsolationRequired StyleRef().HasBlendMode() ? kDescendantIsolationRequired
: kDescendantIsolationNeedsUpdate); : kDescendantIsolationNeedsUpdate);
} }
if (diff.CompositingReasonsChanged()) if (diff.CompositingReasonsChanged())
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this); SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
if (diff.HasDifference()) {
LayoutObject::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
if (diff.HasDifference() && Parent()) {
SVGResourcesCache::UpdateResources(*this); SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff); LayoutSVGResourceContainer::StyleDidChange(*this, diff);
} }
......
...@@ -367,16 +367,19 @@ void LayoutSVGRoot::IntrinsicSizingInfoChanged() { ...@@ -367,16 +367,19 @@ void LayoutSVGRoot::IntrinsicSizingInfoChanged() {
void LayoutSVGRoot::StyleDidChange(StyleDifference diff, void LayoutSVGRoot::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) { const ComputedStyle* old_style) {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutReplaced::StyleDidChange(diff, old_style);
if (diff.NeedsFullLayout()) if (diff.NeedsFullLayout())
SetNeedsBoundariesUpdate(); SetNeedsBoundariesUpdate();
if (old_style && StyleChangeAffectsIntrinsicSize(*old_style)) if (old_style && StyleChangeAffectsIntrinsicSize(*old_style))
IntrinsicSizingInfoChanged(); IntrinsicSizingInfoChanged();
LayoutReplaced::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(To<SVGSVGElement>(*GetNode()), SVGResources::UpdateClipPathFilterMask(To<SVGSVGElement>(*GetNode()),
old_style, StyleRef()); old_style, StyleRef());
if (diff.HasDifference() && Parent()) { if (!Parent())
return;
if (diff.HasDifference()) {
SVGResourcesCache::UpdateResources(*this); SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff); LayoutSVGResourceContainer::StyleDidChange(*this, diff);
} }
......
...@@ -66,9 +66,10 @@ LayoutSVGShape::~LayoutSVGShape() = default; ...@@ -66,9 +66,10 @@ LayoutSVGShape::~LayoutSVGShape() = default;
void LayoutSVGShape::StyleDidChange(StyleDifference diff, void LayoutSVGShape::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) { const ComputedStyle* old_style) {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutSVGModelObject::StyleDidChange(diff, old_style);
transform_uses_reference_box_ = transform_uses_reference_box_ =
TransformHelper::DependsOnReferenceBox(StyleRef()); TransformHelper::DependsOnReferenceBox(StyleRef());
LayoutSVGModelObject::StyleDidChange(diff, old_style);
SVGResources::UpdatePaints(*GetElement(), old_style, StyleRef()); SVGResources::UpdatePaints(*GetElement(), old_style, StyleRef());
// Most of the stroke attributes (caps, joins, miters, width, etc.) will cause // Most of the stroke attributes (caps, joins, miters, width, etc.) will cause
......
...@@ -122,9 +122,10 @@ void LayoutSVGTransformableContainer::StyleDidChange( ...@@ -122,9 +122,10 @@ void LayoutSVGTransformableContainer::StyleDidChange(
StyleDifference diff, StyleDifference diff,
const ComputedStyle* old_style) { const ComputedStyle* old_style) {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutSVGContainer::StyleDidChange(diff, old_style);
transform_uses_reference_box_ = transform_uses_reference_box_ =
TransformHelper::DependsOnReferenceBox(StyleRef()); TransformHelper::DependsOnReferenceBox(StyleRef());
LayoutSVGContainer::StyleDidChange(diff, old_style);
} }
} // namespace blink } // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment