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

Fold SVGResourcesCache::ClientStyleChanged

Since LayoutObject::SetStyle sets needs-paint-property-update based on
StyleDifference we can rely on that and drop the double-work. Make
changes to the 'mask' property also set the property-specific
mask-changed flag to have it be handled by the generic code.

Add LayoutSVGResourceContainer::StyleDidChange matching the tail of the
folded function.

Bug: 1028063
Change-Id: I010232520ec051e6df1bd21408ae64083d91900d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2504314Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#821732}
parent 32b99559
...@@ -144,7 +144,10 @@ void LayoutSVGBlock::StyleDidChange(StyleDifference diff, ...@@ -144,7 +144,10 @@ void LayoutSVGBlock::StyleDidChange(StyleDifference diff,
LayoutBlock::StyleDidChange(diff, old_style); LayoutBlock::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef()); SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
SVGResourcesCache::ClientStyleChanged(*this, diff); if (diff.HasDifference() && Parent()) {
SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff);
}
} }
void LayoutSVGBlock::MapLocalToAncestor(const LayoutBoxModelObject* ancestor, void LayoutSVGBlock::MapLocalToAncestor(const LayoutBoxModelObject* ancestor,
......
...@@ -141,7 +141,10 @@ void LayoutSVGInline::StyleDidChange(StyleDifference diff, ...@@ -141,7 +141,10 @@ void LayoutSVGInline::StyleDidChange(StyleDifference diff,
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());
SVGResourcesCache::ClientStyleChanged(*this, diff); if (diff.HasDifference() && Parent()) {
SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff);
}
} }
void LayoutSVGInline::AddChild(LayoutObject* child, void LayoutSVGInline::AddChild(LayoutObject* child,
......
...@@ -166,7 +166,10 @@ void LayoutSVGModelObject::StyleDidChange(StyleDifference diff, ...@@ -166,7 +166,10 @@ void LayoutSVGModelObject::StyleDidChange(StyleDifference diff,
LayoutObject::StyleDidChange(diff, old_style); LayoutObject::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef()); SVGResources::UpdateClipPathFilterMask(*GetElement(), old_style, StyleRef());
SVGResourcesCache::ClientStyleChanged(*this, diff); if (diff.HasDifference() && Parent()) {
SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff);
}
} }
void LayoutSVGModelObject::InsertedIntoTree() { void LayoutSVGModelObject::InsertedIntoTree() {
......
...@@ -240,4 +240,25 @@ void LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation( ...@@ -240,4 +240,25 @@ void LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(
} }
} }
static inline bool IsLayoutObjectOfResourceContainer(
const LayoutObject& layout_object) {
const LayoutObject* current = &layout_object;
while (current) {
if (current->IsSVGResourceContainer())
return true;
current = current->Parent();
}
return false;
}
void LayoutSVGResourceContainer::StyleDidChange(LayoutObject& object,
StyleDifference diff) {
// If this LayoutObject is the child of a resource container and
// it requires repainting because of changes to CSS properties
// such as 'visibility', upgrade to invalidate layout.
bool needs_layout = diff.NeedsPaintInvalidation() &&
IsLayoutObjectOfResourceContainer(object);
MarkForLayoutAndParentResourceInvalidation(object, needs_layout);
}
} // namespace blink } // namespace blink
...@@ -78,6 +78,7 @@ class LayoutSVGResourceContainer : public LayoutSVGHiddenContainer { ...@@ -78,6 +78,7 @@ class LayoutSVGResourceContainer : public LayoutSVGHiddenContainer {
static void MarkForLayoutAndParentResourceInvalidation( static void MarkForLayoutAndParentResourceInvalidation(
LayoutObject&, LayoutObject&,
bool needs_layout = true); bool needs_layout = true);
static void StyleDidChange(LayoutObject&, StyleDifference);
void ClearInvalidationMask() { void ClearInvalidationMask() {
NOT_DESTROYED(); NOT_DESTROYED();
......
...@@ -373,7 +373,10 @@ void LayoutSVGRoot::StyleDidChange(StyleDifference diff, ...@@ -373,7 +373,10 @@ void LayoutSVGRoot::StyleDidChange(StyleDifference diff,
LayoutReplaced::StyleDidChange(diff, old_style); LayoutReplaced::StyleDidChange(diff, old_style);
SVGResources::UpdateClipPathFilterMask(To<SVGSVGElement>(*GetNode()), SVGResources::UpdateClipPathFilterMask(To<SVGSVGElement>(*GetNode()),
old_style, StyleRef()); old_style, StyleRef());
SVGResourcesCache::ClientStyleChanged(*this, diff); if (diff.HasDifference() && Parent()) {
SVGResourcesCache::UpdateResources(*this);
LayoutSVGResourceContainer::StyleDidChange(*this, diff);
}
} }
bool LayoutSVGRoot::IsChildAllowed(LayoutObject* child, bool LayoutSVGRoot::IsChildAllowed(LayoutObject* child,
......
...@@ -20,9 +20,7 @@ ...@@ -20,9 +20,7 @@
#include "third_party/blink/renderer/core/layout/svg/svg_resources_cache.h" #include "third_party/blink/renderer/core/layout/svg/svg_resources_cache.h"
#include <memory> #include <memory>
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_paint_server.h"
#include "third_party/blink/renderer/core/layout/svg/svg_resources.h" #include "third_party/blink/renderer/core/layout/svg/svg_resources.h"
#include "third_party/blink/renderer/core/layout/svg/svg_resources_cycle_solver.h" #include "third_party/blink/renderer/core/layout/svg/svg_resources_cycle_solver.h"
#include "third_party/blink/renderer/core/svg/svg_document_extensions.h" #include "third_party/blink/renderer/core/svg/svg_document_extensions.h"
...@@ -88,43 +86,6 @@ static inline bool LayoutObjectCanHaveResources( ...@@ -88,43 +86,6 @@ static inline bool LayoutObjectCanHaveResources(
!layout_object.IsSVGInlineText(); !layout_object.IsSVGInlineText();
} }
static inline bool IsLayoutObjectOfResourceContainer(
const LayoutObject& layout_object) {
const LayoutObject* current = &layout_object;
while (current) {
if (current->IsSVGResourceContainer())
return true;
current = current->Parent();
}
return false;
}
void SVGResourcesCache::ClientStyleChanged(LayoutObject& layout_object,
StyleDifference diff) {
DCHECK(layout_object.GetNode());
DCHECK(layout_object.GetNode()->IsSVGElement());
if (!diff.HasDifference() || !layout_object.Parent())
return;
// LayoutObjects for SVGFE*Element should not be calling this function.
DCHECK(!layout_object.IsSVGFilterPrimitive());
// Dynamic changes of CSS properties like 'clip-path' may require us to
// recompute the associated resources for a LayoutObject.
if (UpdateResources(layout_object))
layout_object.SetNeedsPaintPropertyUpdate();
// If this layoutObject is the child of ResourceContainer and it require
// repainting that changes of CSS properties such as 'visibility',
// request repainting.
bool needs_layout = diff.NeedsPaintInvalidation() &&
IsLayoutObjectOfResourceContainer(layout_object);
LayoutSVGResourceContainer::MarkForLayoutAndParentResourceInvalidation(
layout_object, needs_layout);
}
bool SVGResourcesCache::AddResources(LayoutObject& layout_object) { bool SVGResourcesCache::AddResources(LayoutObject& layout_object) {
DCHECK(LayoutObjectCanHaveResources(layout_object)); DCHECK(LayoutObjectCanHaveResources(layout_object));
SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument()); SVGResourcesCache& cache = ResourcesCache(layout_object.GetDocument());
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_RESOURCES_CACHE_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_SVG_SVG_RESOURCES_CACHE_H_
#include <memory> #include <memory>
#include "third_party/blink/renderer/core/style/style_difference.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h"
...@@ -42,9 +41,6 @@ class SVGResourcesCache { ...@@ -42,9 +41,6 @@ class SVGResourcesCache {
static SVGResources* CachedResourcesForLayoutObject(const LayoutObject&); static SVGResources* CachedResourcesForLayoutObject(const LayoutObject&);
// Called from all SVG layoutObjects styleDidChange() methods.
static void ClientStyleChanged(LayoutObject&, StyleDifference);
// Called when an SVG LayoutObject has been added to the tree. // Called when an SVG LayoutObject has been added to the tree.
// Returns true if an SVGResources object was created. // Returns true if an SVGResources object was created.
static bool AddResources(LayoutObject&); static bool AddResources(LayoutObject&);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "third_party/blink/renderer/core/style/svg_computed_style.h" #include "third_party/blink/renderer/core/style/svg_computed_style.h"
#include "third_party/blink/renderer/core/style/data_equivalency.h"
#include "third_party/blink/renderer/core/style/style_difference.h" #include "third_party/blink/renderer/core/style/style_difference.h"
#include "third_party/blink/renderer/core/style/style_svg_resource.h" #include "third_party/blink/renderer/core/style/style_svg_resource.h"
...@@ -125,6 +126,9 @@ StyleDifference SVGComputedStyle::Diff(const SVGComputedStyle& other) const { ...@@ -125,6 +126,9 @@ StyleDifference SVGComputedStyle::Diff(const SVGComputedStyle& other) const {
style_difference.SetNeedsPaintInvalidation(); style_difference.SetNeedsPaintInvalidation();
} }
if (!DataEquivalent(resources->masker, other.resources->masker))
style_difference.SetMaskChanged();
return style_difference; return style_difference;
} }
......
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