Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2401343002: Tracking filter mutation via SVGElementProxy (Closed)
Patch Set: referenceChanged -> proxiedElementChanged Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/PaintLayer.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
index a7ed7bdb3a8a6fcdf93de359267a0189b4915a90..1f002d6f57f81ace6c595f2fa3ff475956d6119d 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -188,8 +188,10 @@ PaintLayer::PaintLayer(LayoutBoxModelObject* layoutObject)
}
PaintLayer::~PaintLayer() {
- if (m_rareData && m_rareData->filterInfo)
+ if (m_rareData && m_rareData->filterInfo) {
+ layoutObject()->styleRef().filter().removeClient(m_rareData->filterInfo);
m_rareData->filterInfo->clearLayer();
+ }
if (layoutObject()->frame() && layoutObject()->frame()->page()) {
if (ScrollingCoordinator* scrollingCoordinator =
layoutObject()->frame()->page()->scrollingCoordinator())
@@ -2654,7 +2656,8 @@ void PaintLayer::ensureCompositedLayerMapping() {
m_rareData->compositedLayerMapping->setNeedsGraphicsLayerUpdate(
GraphicsLayerUpdateSubtree);
- updateOrRemoveFilterEffect();
+ if (PaintLayerFilterInfo* filterInfo = this->filterInfo())
+ filterInfo->invalidateFilterChain();
}
void PaintLayer::clearCompositedLayerMapping(bool layerBeingDestroyed) {
@@ -2672,8 +2675,11 @@ void PaintLayer::clearCompositedLayerMapping(bool layerBeingDestroyed) {
if (m_rareData)
m_rareData->compositedLayerMapping.reset();
- if (!layerBeingDestroyed)
- updateOrRemoveFilterEffect();
+ if (layerBeingDestroyed)
+ return;
+
+ if (PaintLayerFilterInfo* filterInfo = this->filterInfo())
+ filterInfo->invalidateFilterChain();
}
void PaintLayer::setGroupedMapping(CompositedLayerMapping* groupedMapping,
@@ -2868,9 +2874,17 @@ void PaintLayer::updateFilters(const ComputedStyle* oldStyle,
if (!newStyle.hasFilterInducingProperty() &&
(!oldStyle || !oldStyle->hasFilterInducingProperty()))
return;
-
- updateOrRemoveFilterClients();
- updateOrRemoveFilterEffect();
+ const bool hadFilterInfo = filterInfo();
+ if (newStyle.hasFilterInducingProperty())
+ newStyle.filter().addClient(&ensureFilterInfo());
+ if (hadFilterInfo && oldStyle)
+ oldStyle->filter().removeClient(filterInfo());
+ if (!newStyle.hasFilterInducingProperty()) {
+ removeFilterInfo();
+ return;
+ }
+ if (PaintLayerFilterInfo* filterInfo = this->filterInfo())
+ filterInfo->invalidateFilterChain();
}
bool PaintLayer::attemptDirectCompositingUpdate(StyleDifference diff,
@@ -3015,6 +3029,13 @@ PaintLayerFilterInfo& PaintLayer::ensureFilterInfo() {
return *rareData.filterInfo;
}
+void PaintLayer::removeFilterInfo() {
+ if (!m_rareData || !m_rareData->filterInfo)
+ return;
+ m_rareData->filterInfo->clearLayer();
+ m_rareData->filterInfo = nullptr;
+}
+
void PaintLayer::removeAncestorOverflowLayer(const PaintLayer* removedLayer) {
// If the current ancestor overflow layer does not match the removed layer
// the ancestor overflow layer has changed so we can stop searching.
@@ -3037,27 +3058,11 @@ void PaintLayer::removeAncestorOverflowLayer(const PaintLayer* removedLayer) {
}
}
-void PaintLayer::updateOrRemoveFilterClients() {
- const auto& filter = layoutObject()->style()->filter();
- if (filter.isEmpty() && m_rareData && m_rareData->filterInfo) {
- m_rareData->filterInfo->clearLayer();
- m_rareData->filterInfo = nullptr;
- } else if (filter.hasReferenceFilter()) {
- ensureFilterInfo().updateReferenceFilterClients(filter);
- } else if (filterInfo()) {
- filterInfo()->clearFilterReferences();
- }
-}
-
-FilterEffect* PaintLayer::updateFilterEffect() const {
+FilterEffect* PaintLayer::lastFilterEffect() const {
// TODO(chrishtr): ensure (and assert) that compositing is clean here.
-
if (!paintsWithFilters())
return nullptr;
-
PaintLayerFilterInfo* filterInfo = this->filterInfo();
-
- // Should have been added by updateOrRemoveFilterEffect().
DCHECK(filterInfo);
if (filterInfo->lastEffect())
@@ -3074,16 +3079,12 @@ FilterEffect* PaintLayer::updateFilterEffect() const {
return filterInfo->lastEffect();
}
-FilterEffect* PaintLayer::lastFilterEffect() const {
- return updateFilterEffect();
-}
-
FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const {
if (!hasFilterThatMovesPixels())
return rect;
// Ensure the filter-chain is refreshed wrt reference filters.
- updateFilterEffect();
+ lastFilterEffect();
esprehn 2016/10/25 01:18:42 This is strange that it has side effects. Can we r
fs 2016/10/25 15:00:53 Sure. That would mean that every time this is call
FilterOperations filterOperations =
addReflectionToFilterOperations(layoutObject()->styleRef());
@@ -3107,19 +3108,6 @@ bool PaintLayer::hasFilterThatMovesPixels() const {
return false;
}
-void PaintLayer::updateOrRemoveFilterEffect() {
- // FilterEffectBuilder is only used to render the filters in software mode,
- // so we always need to run updateOrRemoveFilterEffect after the composited
- // mode might have changed for this layer.
- if (!paintsWithFilters()) {
- if (PaintLayerFilterInfo* filterInfo = this->filterInfo())
- filterInfo->setLastEffect(nullptr);
- return;
- }
-
- ensureFilterInfo().setLastEffect(nullptr);
-}
-
void PaintLayer::filterNeedsPaintInvalidation() {
{
DeprecatedScheduleStyleRecalcDuringLayout marker(

Powered by Google App Engine
This is Rietveld 408576698