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

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

Issue 2617903002: Convert recursion to iteration in clearClipRectsIncludingDescendants (Closed)
Patch Set: none Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerClipper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp b/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp
index 3f8a6de6090b6dedea8057046b768ba5a7b09be4..05403b54b938ad0469cfb1ffbad9ce26ad82448f 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp
@@ -177,28 +177,32 @@ ClipRects& PaintLayerClipper::getClipRects(
return storeClipRectsInCache(context, parentClipRects, *clipRects);
}
-void PaintLayerClipper::clearClipRectsIncludingDescendants() {
+void PaintLayerClipper::clearCache(ClipRectsCacheSlot cacheSlot) {
wkorman 2017/01/06 02:51:50 Current unit tests in PaintLayerClipperTest look f
+ if (cacheSlot == NumberOfClipRectsCacheSlots)
+ m_layer.clearClipRectsCache();
+ else if (ClipRectsCache* cache = m_layer.clipRectsCache())
+ cache->clear(cacheSlot);
+
if (m_geometryMapper)
m_geometryMapper.reset(new GeometryMapper);
- m_layer.clearClipRectsCache();
+}
- for (PaintLayer* layer = m_layer.firstChild(); layer;
- layer = layer->nextSibling()) {
- layer->clipper().clearClipRectsIncludingDescendants();
- }
+void PaintLayerClipper::clearClipRectsIncludingDescendants() {
+ clearClipRectsIncludingDescendants(NumberOfClipRectsCacheSlots);
}
void PaintLayerClipper::clearClipRectsIncludingDescendants(
ClipRectsCacheSlot cacheSlot) {
- if (m_geometryMapper)
- m_geometryMapper.reset(new GeometryMapper);
-
- if (ClipRectsCache* cache = m_layer.clipRectsCache())
- cache->clear(cacheSlot);
-
- for (PaintLayer* layer = m_layer.firstChild(); layer;
- layer = layer->nextSibling()) {
- layer->clipper().clearClipRectsIncludingDescendants(cacheSlot);
+ std::stack<const PaintLayer*> layers;
+ layers.push(&m_layer);
+
+ while (!layers.empty()) {
+ const PaintLayer* currentLayer = layers.top();
+ layers.pop();
+ currentLayer->clipper().clearCache(cacheSlot);
+ for (const PaintLayer* layer = currentLayer->firstChild(); layer;
+ layer = layer->nextSibling())
+ layers.push(layer);
}
}
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerClipper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698