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

Move SVGResourcesCache::Client{WasAddedTo,WillBeRemovedFrom}Tree calls

Rather than letting the container of the LayoutObject manage the
SVGResources, have it manage it itself via InsertedIntoTree() and
WillBeRemovedFromTree() overrides.
This allows limiting the checks in the called methods a bit since we
know what LayoutObjects it's being called on.

Bug: 1028063
Change-Id: I54b28336649c6c200dcf4c220fd869fe66770119
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450050Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#814128}
parent 587b677a
......@@ -55,6 +55,7 @@ void LayoutSVGBlock::WillBeDestroyed() {
void LayoutSVGBlock::InsertedIntoTree() {
NOT_DESTROYED();
LayoutBlockFlow::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this);
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
......@@ -63,6 +64,7 @@ void LayoutSVGBlock::InsertedIntoTree() {
void LayoutSVGBlock::WillBeRemovedFromTree() {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this);
LayoutBlockFlow::WillBeRemovedFromTree();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
......
......@@ -91,7 +91,6 @@ void LayoutSVGContainer::AddChild(LayoutObject* child,
LayoutObject* before_child) {
NOT_DESTROYED();
LayoutSVGModelObject::AddChild(child, before_child);
SVGResourcesCache::ClientWasAddedToTree(*child);
bool should_isolate_descendants =
(child->IsBlendingAllowed() && child->StyleRef().HasBlendMode()) ||
......@@ -102,7 +101,6 @@ void LayoutSVGContainer::AddChild(LayoutObject* child,
void LayoutSVGContainer::RemoveChild(LayoutObject* child) {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*child);
LayoutSVGModelObject::RemoveChild(child);
bool had_non_isolated_descendants =
......
......@@ -148,14 +148,12 @@ void LayoutSVGInline::AddChild(LayoutObject* child,
LayoutObject* before_child) {
NOT_DESTROYED();
LayoutInline::AddChild(child, before_child);
SVGResourcesCache::ClientWasAddedToTree(*child);
LayoutSVGText::NotifySubtreeStructureChanged(
this, layout_invalidation_reason::kChildChanged);
}
void LayoutSVGInline::RemoveChild(LayoutObject* child) {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*child);
LayoutSVGText::NotifySubtreeStructureChanged(
this, layout_invalidation_reason::kChildChanged);
LayoutInline::RemoveChild(child);
......@@ -164,6 +162,7 @@ void LayoutSVGInline::RemoveChild(LayoutObject* child) {
void LayoutSVGInline::InsertedIntoTree() {
NOT_DESTROYED();
LayoutInline::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this);
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
......@@ -172,6 +171,7 @@ void LayoutSVGInline::InsertedIntoTree() {
void LayoutSVGInline::WillBeRemovedFromTree() {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this);
LayoutInline::WillBeRemovedFromTree();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
......
......@@ -178,6 +178,7 @@ void LayoutSVGModelObject::StyleDidChange(StyleDifference diff,
void LayoutSVGModelObject::InsertedIntoTree() {
NOT_DESTROYED();
LayoutObject::InsertedIntoTree();
SVGResourcesCache::ClientWasAddedToTree(*this);
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
SVGLayoutSupport::NotifySVGRootOfChangedCompositingReasons(this);
......@@ -186,6 +187,7 @@ void LayoutSVGModelObject::InsertedIntoTree() {
void LayoutSVGModelObject::WillBeRemovedFromTree() {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*this);
LayoutObject::WillBeRemovedFromTree();
if (CompositingReasonFinder::DirectReasonsForSVGChildPaintProperties(*this) !=
CompositingReason::kNone) {
......
......@@ -397,7 +397,6 @@ bool LayoutSVGRoot::IsChildAllowed(LayoutObject* child,
void LayoutSVGRoot::AddChild(LayoutObject* child, LayoutObject* before_child) {
NOT_DESTROYED();
LayoutReplaced::AddChild(child, before_child);
SVGResourcesCache::ClientWasAddedToTree(*child);
bool should_isolate_descendants =
(child->IsBlendingAllowed() && child->StyleRef().HasBlendMode()) ||
......@@ -408,7 +407,6 @@ void LayoutSVGRoot::AddChild(LayoutObject* child, LayoutObject* before_child) {
void LayoutSVGRoot::RemoveChild(LayoutObject* child) {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*child);
LayoutReplaced::RemoveChild(child);
bool had_non_isolated_descendants =
......
......@@ -402,16 +402,12 @@ bool LayoutSVGText::IsObjectBoundingBoxValid() const {
void LayoutSVGText::AddChild(LayoutObject* child, LayoutObject* before_child) {
NOT_DESTROYED();
LayoutSVGBlock::AddChild(child, before_child);
SVGResourcesCache::ClientWasAddedToTree(*child);
SubtreeStructureChanged(layout_invalidation_reason::kChildChanged);
}
void LayoutSVGText::RemoveChild(LayoutObject* child) {
NOT_DESTROYED();
SVGResourcesCache::ClientWillBeRemovedFromTree(*child);
SubtreeStructureChanged(layout_invalidation_reason::kChildChanged);
LayoutSVGBlock::RemoveChild(child);
}
......
......@@ -201,13 +201,10 @@ void SVGResourcesCache::ResourceReferenceChanged(LayoutObject& layout_object) {
}
void SVGResourcesCache::ClientWasAddedToTree(LayoutObject& layout_object) {
if (!layout_object.GetNode())
return;
DCHECK(LayoutObjectCanHaveResources(layout_object));
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(
layout_object, false);
if (!LayoutObjectCanHaveResources(layout_object))
return;
SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
if (cache.AddResourcesFromLayoutObject(layout_object,
layout_object.StyleRef()))
......@@ -216,13 +213,10 @@ void SVGResourcesCache::ClientWasAddedToTree(LayoutObject& layout_object) {
void SVGResourcesCache::ClientWillBeRemovedFromTree(
LayoutObject& layout_object) {
if (!layout_object.GetNode())
return;
DCHECK(LayoutObjectCanHaveResources(layout_object));
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(
layout_object, false);
if (!LayoutObjectCanHaveResources(layout_object))
return;
SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
if (cache.RemoveResourcesFromLayoutObject(layout_object))
layout_object.SetNeedsPaintPropertyUpdate();
......
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