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) {
void LayoutSVGBlock::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
NOT_DESTROYED();
LayoutBlock::StyleDidChange(diff, old_style);
transform_uses_reference_box_ =
TransformHelper::DependsOnReferenceBox(StyleRef());
......@@ -127,19 +129,19 @@ void LayoutSVGBlock::StyleDidChange(StyleDifference diff,
SetNeedsTransformUpdate();
}
if (diff.BlendModeChanged() && Parent()) {
SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
if (!Parent())
return;
if (diff.BlendModeChanged()) {
DCHECK(IsBlendingAllowed());
Parent()->DescendantIsolationRequirementsChanged(
StyleRef().HasBlendMode() ? kDescendantIsolationRequired
: kDescendantIsolationNeedsUpdate);
}
if (diff.CompositingReasonsChanged())
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
LayoutBlock::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
if (diff.HasDifference() && Parent()) {
if (diff.HasDifference()) {
SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff);
}
......
......@@ -126,17 +126,20 @@ void LayoutSVGInline::WillBeDestroyed() {
void LayoutSVGInline::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
NOT_DESTROYED();
LayoutInline::StyleDidChange(diff, old_style);
if (diff.NeedsFullLayout())
SetNeedsBoundariesUpdate();
if (diff.CompositingReasonsChanged())
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
LayoutInline::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(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);
LayoutSVGResourceContainer::StyleDidChange(*this, diff);
}
......
......@@ -139,25 +139,27 @@ bool LayoutSVGModelObject::CheckForImplicitTransformChange(
void LayoutSVGModelObject::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
NOT_DESTROYED();
LayoutObject::StyleDidChange(diff, old_style);
if (diff.NeedsFullLayout()) {
SetNeedsBoundariesUpdate();
if (diff.TransformChanged())
SetNeedsTransformUpdate();
}
if (diff.BlendModeChanged() && Parent() && !IsSVGHiddenContainer()) {
SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
if (!Parent())
return;
if (diff.BlendModeChanged() && !IsSVGHiddenContainer()) {
DCHECK(IsBlendingAllowed());
Parent()->DescendantIsolationRequirementsChanged(
StyleRef().HasBlendMode() ? kDescendantIsolationRequired
: kDescendantIsolationNeedsUpdate);
}
if (diff.CompositingReasonsChanged())
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
LayoutObject::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
if (diff.HasDifference() && Parent()) {
if (diff.HasDifference()) {
SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff);
}
......
......@@ -367,16 +367,19 @@ void LayoutSVGRoot::IntrinsicSizingInfoChanged() {
void LayoutSVGRoot::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
NOT_DESTROYED();
LayoutReplaced::StyleDidChange(diff, old_style);
if (diff.NeedsFullLayout())
SetNeedsBoundariesUpdate();
if (old_style && StyleChangeAffectsIntrinsicSize(*old_style))
IntrinsicSizingInfoChanged();
LayoutReplaced::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(To<SVGSVGElement>(*GetNode()),
old_style, StyleRef());
if (diff.HasDifference() && Parent()) {
if (!Parent())
return;
if (diff.HasDifference()) {
SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff);
}
......
......@@ -66,9 +66,10 @@ LayoutSVGShape::~LayoutSVGShape() = default;
void LayoutSVGShape::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
NOT_DESTROYED();
LayoutSVGModelObject::StyleDidChange(diff, old_style);
transform_uses_reference_box_ =
TransformHelper::DependsOnReferenceBox(StyleRef());
LayoutSVGModelObject::StyleDidChange(diff, old_style);
SVGResources::UpdatePaints(*GetElement(), old_style, StyleRef());
// Most of the stroke attributes (caps, joins, miters, width, etc.) will cause
......
......@@ -122,9 +122,10 @@ void LayoutSVGTransformableContainer::StyleDidChange(
StyleDifference diff,
const ComputedStyle* old_style) {
NOT_DESTROYED();
LayoutSVGContainer::StyleDidChange(diff, old_style);
transform_uses_reference_box_ =
TransformHelper::DependsOnReferenceBox(StyleRef());
LayoutSVGContainer::StyleDidChange(diff, old_style);
}
} // 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