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

Fold most of the functions in SVGResourcesCache

Fold

  SVGResourcesCache::ClientDestroyed,
  SVGResourcesCache::ClientWillBeRemovedFromTree and
  SVGResourcesCache::ClientWasAddedToTree

replacing the two former with a more direct RemoveResources(), and the
last with a similar acting AddResources().

Bug: 1028063
Change-Id: Ibf5eba0dc906d75967d9eaddb06ff01025d018e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2501844
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821246}
parent 1f438533
...@@ -47,7 +47,7 @@ SVGElement* LayoutSVGBlock::GetElement() const { ...@@ -47,7 +47,7 @@ SVGElement* LayoutSVGBlock::GetElement() const {
void LayoutSVGBlock::WillBeDestroyed() { void LayoutSVGBlock::WillBeDestroyed() {
NOT_DESTROYED(); NOT_DESTROYED();
SVGResourcesCache::ClientDestroyed(*this); SVGResourcesCache::RemoveResources(*this);
SVGResources::ClearClipPathFilterMask(*GetElement(), Style()); SVGResources::ClearClipPathFilterMask(*GetElement(), Style());
LayoutBlockFlow::WillBeDestroyed(); LayoutBlockFlow::WillBeDestroyed();
} }
...@@ -55,7 +55,10 @@ void LayoutSVGBlock::WillBeDestroyed() { ...@@ -55,7 +55,10 @@ void LayoutSVGBlock::WillBeDestroyed() {
void LayoutSVGBlock::InsertedIntoTree() { void LayoutSVGBlock::InsertedIntoTree() {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutBlockFlow::InsertedIntoTree(); LayoutBlockFlow::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this); LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::AddResources(*this))
SetNeedsPaintPropertyUpdate();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) != if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) { CompositingReason::kNone) {
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this); SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
...@@ -64,7 +67,10 @@ void LayoutSVGBlock::InsertedIntoTree() { ...@@ -64,7 +67,10 @@ void LayoutSVGBlock::InsertedIntoTree() {
void LayoutSVGBlock::WillBeRemovedFromTree() { void LayoutSVGBlock::WillBeRemovedFromTree() {
NOT_DESTROYED(); NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this); LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::RemoveResources(*this))
SetNeedsPaintPropertyUpdate();
LayoutBlockFlow::WillBeRemovedFromTree(); LayoutBlockFlow::WillBeRemovedFromTree();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) != if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) { CompositingReason::kNone) {
......
...@@ -117,7 +117,7 @@ void LayoutSVGInline::AbsoluteQuads(Vector<FloatQuad>& quads, ...@@ -117,7 +117,7 @@ void LayoutSVGInline::AbsoluteQuads(Vector<FloatQuad>& quads,
void LayoutSVGInline::WillBeDestroyed() { void LayoutSVGInline::WillBeDestroyed() {
NOT_DESTROYED(); NOT_DESTROYED();
SVGResourcesCache::ClientDestroyed(*this); SVGResourcesCache::RemoveResources(*this);
SVGResources::ClearClipPathFilterMask(To<SVGElement>(*GetNode()), Style()); SVGResources::ClearClipPathFilterMask(To<SVGElement>(*GetNode()), Style());
SVGResources::ClearPaints(To<SVGElement>(*GetNode()), Style()); SVGResources::ClearPaints(To<SVGElement>(*GetNode()), Style());
LayoutInline::WillBeDestroyed(); LayoutInline::WillBeDestroyed();
...@@ -162,7 +162,10 @@ void LayoutSVGInline::RemoveChild(LayoutObject* child) { ...@@ -162,7 +162,10 @@ void LayoutSVGInline::RemoveChild(LayoutObject* child) {
void LayoutSVGInline::InsertedIntoTree() { void LayoutSVGInline::InsertedIntoTree() {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutInline::InsertedIntoTree(); LayoutInline::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this); LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::AddResources(*this))
SetNeedsPaintPropertyUpdate();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) != if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) { CompositingReason::kNone) {
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this); SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
...@@ -171,7 +174,10 @@ void LayoutSVGInline::InsertedIntoTree() { ...@@ -171,7 +174,10 @@ void LayoutSVGInline::InsertedIntoTree() {
void LayoutSVGInline::WillBeRemovedFromTree() { void LayoutSVGInline::WillBeRemovedFromTree() {
NOT_DESTROYED(); NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this); LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::RemoveResources(*this))
SetNeedsPaintPropertyUpdate();
LayoutInline::WillBeRemovedFromTree(); LayoutInline::WillBeRemovedFromTree();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) != if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) { CompositingReason::kNone) {
......
...@@ -108,7 +108,7 @@ FloatRect LayoutSVGModelObject::LocalBoundingBoxRectForAccessibility() const { ...@@ -108,7 +108,7 @@ FloatRect LayoutSVGModelObject::LocalBoundingBoxRectForAccessibility() const {
void LayoutSVGModelObject::WillBeDestroyed() { void LayoutSVGModelObject::WillBeDestroyed() {
NOT_DESTROYED(); NOT_DESTROYED();
SVGResourcesCache::ClientDestroyed(*this); SVGResourcesCache::RemoveResources(*this);
SVGResources::ClearClipPathFilterMask(*GetElement(), Style()); SVGResources::ClearClipPathFilterMask(*GetElement(), Style());
LayoutObject::WillBeDestroyed(); LayoutObject::WillBeDestroyed();
} }
...@@ -172,7 +172,10 @@ void LayoutSVGModelObject::StyleDidChange(StyleDifference diff, ...@@ -172,7 +172,10 @@ void LayoutSVGModelObject::StyleDidChange(StyleDifference diff,
void LayoutSVGModelObject::InsertedIntoTree() { void LayoutSVGModelObject::InsertedIntoTree() {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutObject::InsertedIntoTree(); LayoutObject::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this); LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::AddResources(*this))
SetNeedsPaintPropertyUpdate();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) != if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) { CompositingReason::kNone) {
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this); SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
...@@ -181,7 +184,10 @@ void LayoutSVGModelObject::InsertedIntoTree() { ...@@ -181,7 +184,10 @@ void LayoutSVGModelObject::InsertedIntoTree() {
void LayoutSVGModelObject::WillBeRemovedFromTree() { void LayoutSVGModelObject::WillBeRemovedFromTree() {
NOT_DESTROYED(); NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this); LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::RemoveResources(*this))
SetNeedsPaintPropertyUpdate();
LayoutObject::WillBeRemovedFromTree(); LayoutObject::WillBeRemovedFromTree();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) != if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) { CompositingReason::kNone) {
......
...@@ -318,7 +318,7 @@ void LayoutSVGRoot::PaintReplaced(const PaintInfo& paint_info, ...@@ -318,7 +318,7 @@ void LayoutSVGRoot::PaintReplaced(const PaintInfo& paint_info,
void LayoutSVGRoot::WillBeDestroyed() { void LayoutSVGRoot::WillBeDestroyed() {
NOT_DESTROYED(); NOT_DESTROYED();
SVGResourcesCache::ClientDestroyed(*this); SVGResourcesCache::RemoveResources(*this);
SVGResources::ClearClipPathFilterMask(To<SVGSVGElement>(*GetNode()), Style()); SVGResources::ClearClipPathFilterMask(To<SVGSVGElement>(*GetNode()), Style());
LayoutReplaced::WillBeDestroyed(); LayoutReplaced::WillBeDestroyed();
} }
...@@ -434,12 +434,18 @@ void LayoutSVGRoot::DescendantIsolationRequirementsChanged( ...@@ -434,12 +434,18 @@ void LayoutSVGRoot::DescendantIsolationRequirementsChanged(
void LayoutSVGRoot::InsertedIntoTree() { void LayoutSVGRoot::InsertedIntoTree() {
NOT_DESTROYED(); NOT_DESTROYED();
LayoutReplaced::InsertedIntoTree(); LayoutReplaced::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this); LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::AddResources(*this))
SetNeedsPaintPropertyUpdate();
} }
void LayoutSVGRoot::WillBeRemovedFromTree() { void LayoutSVGRoot::WillBeRemovedFromTree() {
NOT_DESTROYED(); NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this); LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::RemoveResources(*this))
SetNeedsPaintPropertyUpdate();
LayoutReplaced::WillBeRemovedFromTree(); LayoutReplaced::WillBeRemovedFromTree();
} }
......
...@@ -125,26 +125,17 @@ void SVGResourcesCache::ClientStyleChanged(LayoutObject& layout_object, ...@@ -125,26 +125,17 @@ void SVGResourcesCache::ClientStyleChanged(LayoutObject& layout_object,
layout_object, needs_layout); layout_object, needs_layout);
} }
void SVGResourcesCache::ClientWasAddedToTree(LayoutObject& layout_object) { bool SVGResourcesCache::AddResources(LayoutObject& layout_object) {
DCHECK(LayoutObjectCanHaveResources(layout_object)); DCHECK(LayoutObjectCanHaveResources(layout_object));
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(
layout_object, false);
SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument()); SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
if (cache.AddResourcesFromLayoutObject(layout_object, return cache.AddResourcesFromLayoutObject(layout_object,
layout_object.StyleRef())) layout_object.StyleRef());
layout_object.SetNeedsPaintPropertyUpdate();
} }
void SVGResourcesCache::ClientWillBeRemovedFromTree( bool SVGResourcesCache::RemoveResources(LayoutObject& layout_object) {
LayoutObject& layout_object) {
DCHECK(LayoutObjectCanHaveResources(layout_object)); DCHECK(LayoutObjectCanHaveResources(layout_object));
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(
layout_object, false);
SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument()); SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
if (cache.RemoveResourcesFromLayoutObject(layout_object)) return cache.RemoveResourcesFromLayoutObject(layout_object);
layout_object.SetNeedsPaintPropertyUpdate();
} }
bool SVGResourcesCache::UpdateResources(LayoutObject& layout_object) { bool SVGResourcesCache::UpdateResources(LayoutObject& layout_object) {
...@@ -154,11 +145,6 @@ bool SVGResourcesCache::UpdateResources(LayoutObject& layout_object) { ...@@ -154,11 +145,6 @@ bool SVGResourcesCache::UpdateResources(LayoutObject& layout_object) {
layout_object.StyleRef()); layout_object.StyleRef());
} }
void SVGResourcesCache::ClientDestroyed(LayoutObject& layout_object) {
SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
cache.RemoveResourcesFromLayoutObject(layout_object);
}
SVGResourcesCache::TemporaryStyleScope::TemporaryStyleScope( SVGResourcesCache::TemporaryStyleScope::TemporaryStyleScope(
LayoutObject& layout_object, LayoutObject& layout_object,
const ComputedStyle& style, const ComputedStyle& style,
......
...@@ -42,19 +42,17 @@ class SVGResourcesCache { ...@@ -42,19 +42,17 @@ class SVGResourcesCache {
static SVGResources* CachedResourcesForLayoutObject(const LayoutObject&); static SVGResources* CachedResourcesForLayoutObject(const LayoutObject&);
// Called from all SVG layoutObjects addChild() methods.
static void ClientWasAddedToTree(LayoutObject&);
// Called from all SVG layoutObjects removeChild() methods.
static void ClientWillBeRemovedFromTree(LayoutObject&);
// Called from all SVG layoutObjects destroy() methods - except for
// LayoutSVGResourceContainer.
static void ClientDestroyed(LayoutObject&);
// Called from all SVG layoutObjects styleDidChange() methods. // Called from all SVG layoutObjects styleDidChange() methods.
static void ClientStyleChanged(LayoutObject&, StyleDifference); static void ClientStyleChanged(LayoutObject&, StyleDifference);
// Called when an SVG LayoutObject has been added to the tree.
// Returns true if an SVGResources object was created.
static bool AddResources(LayoutObject&);
// Called when an SVG LayoutObject has been removed from the tree.
// Returns true if an SVGResources object was destroyed.
static bool RemoveResources(LayoutObject&);
// Called when the target element of a resource referenced by the // Called when the target element of a resource referenced by the
// LayoutObject may have changed and we need to recreate the // LayoutObject may have changed and we need to recreate the
// associated SVGResources object. // associated SVGResources object.
......
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