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 {
void LayoutSVGBlock::WillBeDestroyed() {
NOT_DESTROYED();
SVGResourcesCache::ClientDestroyed(*this);
SVGResourcesCache::RemoveResources(*this);
SVGResources::ClearClipPathFilterMask(*GetElement(), Style());
LayoutBlockFlow::WillBeDestroyed();
}
......@@ -55,7 +55,10 @@ void LayoutSVGBlock::WillBeDestroyed() {
void LayoutSVGBlock::InsertedIntoTree() {
NOT_DESTROYED();
LayoutBlockFlow::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this);
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::AddResources(*this))
SetNeedsPaintPropertyUpdate();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
......@@ -64,7 +67,10 @@ void LayoutSVGBlock::InsertedIntoTree() {
void LayoutSVGBlock::WillBeRemovedFromTree() {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this);
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::RemoveResources(*this))
SetNeedsPaintPropertyUpdate();
LayoutBlockFlow::WillBeRemovedFromTree();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
......
......@@ -117,7 +117,7 @@ void LayoutSVGInline::AbsoluteQuads(Vector<FloatQuad>& quads,
void LayoutSVGInline::WillBeDestroyed() {
NOT_DESTROYED();
SVGResourcesCache::ClientDestroyed(*this);
SVGResourcesCache::RemoveResources(*this);
SVGResources::ClearClipPathFilterMask(To<SVGElement>(*GetNode()), Style());
SVGResources::ClearPaints(To<SVGElement>(*GetNode()), Style());
LayoutInline::WillBeDestroyed();
......@@ -162,7 +162,10 @@ void LayoutSVGInline::RemoveChild(LayoutObject* child) {
void LayoutSVGInline::InsertedIntoTree() {
NOT_DESTROYED();
LayoutInline::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this);
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::AddResources(*this))
SetNeedsPaintPropertyUpdate();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
......@@ -171,7 +174,10 @@ void LayoutSVGInline::InsertedIntoTree() {
void LayoutSVGInline::WillBeRemovedFromTree() {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this);
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::RemoveResources(*this))
SetNeedsPaintPropertyUpdate();
LayoutInline::WillBeRemovedFromTree();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
......
......@@ -108,7 +108,7 @@ FloatRect LayoutSVGModelObject::LocalBoundingBoxRectForAccessibility() const {
void LayoutSVGModelObject::WillBeDestroyed() {
NOT_DESTROYED();
SVGResourcesCache::ClientDestroyed(*this);
SVGResourcesCache::RemoveResources(*this);
SVGResources::ClearClipPathFilterMask(*GetElement(), Style());
LayoutObject::WillBeDestroyed();
}
......@@ -172,7 +172,10 @@ void LayoutSVGModelObject::StyleDidChange(StyleDifference diff,
void LayoutSVGModelObject::InsertedIntoTree() {
NOT_DESTROYED();
LayoutObject::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this);
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::AddResources(*this))
SetNeedsPaintPropertyUpdate();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
......@@ -181,7 +184,10 @@ void LayoutSVGModelObject::InsertedIntoTree() {
void LayoutSVGModelObject::WillBeRemovedFromTree() {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this);
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::RemoveResources(*this))
SetNeedsPaintPropertyUpdate();
LayoutObject::WillBeRemovedFromTree();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
......
......@@ -318,7 +318,7 @@ void LayoutSVGRoot::PaintReplaced(const PaintInfo& paint_info,
void LayoutSVGRoot::WillBeDestroyed() {
NOT_DESTROYED();
SVGResourcesCache::ClientDestroyed(*this);
SVGResourcesCache::RemoveResources(*this);
SVGResources::ClearClipPathFilterMask(To<SVGSVGElement>(*GetNode()), Style());
LayoutReplaced::WillBeDestroyed();
}
......@@ -434,12 +434,18 @@ void LayoutSVGRoot::DescendantIsolationRequirementsChanged(
void LayoutSVGRoot::InsertedIntoTree() {
NOT_DESTROYED();
LayoutReplaced::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this);
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::AddResources(*this))
SetNeedsPaintPropertyUpdate();
}
void LayoutSVGRoot::WillBeRemovedFromTree() {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this);
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(*this,
false);
if (SVGResourcesCache::RemoveResources(*this))
SetNeedsPaintPropertyUpdate();
LayoutReplaced::WillBeRemovedFromTree();
}
......
......@@ -125,26 +125,17 @@ void SVGResourcesCache::ClientStyleChanged(LayoutObject& layout_object,
layout_object, needs_layout);
}
void SVGResourcesCache::ClientWasAddedToTree(LayoutObject& layout_object) {
bool SVGResourcesCache::AddResources(LayoutObject& layout_object) {
DCHECK(LayoutObjectCanHaveResources(layout_object));
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(
layout_object, false);
SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
if (cache.AddResourcesFromLayoutObject(layout_object,
layout_object.StyleRef()))
layout_object.SetNeedsPaintPropertyUpdate();
return cache.AddResourcesFromLayoutObject(layout_object,
layout_object.StyleRef());
}
void SVGResourcesCache::ClientWillBeRemovedFromTree(
LayoutObject& layout_object) {
bool SVGResourcesCache::RemoveResources(LayoutObject& layout_object) {
DCHECK(LayoutObjectCanHaveResources(layout_object));
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(
layout_object, false);
SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
if (cache.RemoveResourcesFromLayoutObject(layout_object))
layout_object.SetNeedsPaintPropertyUpdate();
return cache.RemoveResourcesFromLayoutObject(layout_object);
}
bool SVGResourcesCache::UpdateResources(LayoutObject& layout_object) {
......@@ -154,11 +145,6 @@ bool SVGResourcesCache::UpdateResources(LayoutObject& layout_object) {
layout_object.StyleRef());
}
void SVGResourcesCache::ClientDestroyed(LayoutObject& layout_object) {
SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
cache.RemoveResourcesFromLayoutObject(layout_object);
}
SVGResourcesCache::TemporaryStyleScope::TemporaryStyleScope(
LayoutObject& layout_object,
const ComputedStyle& style,
......
......@@ -42,19 +42,17 @@ class SVGResourcesCache {
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.
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
// LayoutObject may have changed and we need to recreate the
// 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