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

Unified Diff: Source/core/rendering/RenderObject.cpp

Issue 19614004: Compositor hit test performance improvement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merge with trunk Created 7 years, 5 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 | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/RenderText.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderObject.cpp
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp
index d483226957a71fb8e6af11417f0f3653a2786c32..657660831f1c9f1acec3595bf607387e6701cc62 100644
--- a/Source/core/rendering/RenderObject.cpp
+++ b/Source/core/rendering/RenderObject.cpp
@@ -2295,14 +2295,34 @@ void RenderObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const
return;
}
- this->addLayerHitTestRects(layerRects, currentLayer, layerOffset);
+ this->addLayerHitTestRects(layerRects, currentLayer, layerOffset, LayoutRect());
}
-void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const RenderLayer* currentLayer, const LayoutPoint& layerOffset) const
+void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const RenderLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const
{
ASSERT(currentLayer);
ASSERT(currentLayer == this->enclosingLayer());
+ // Compute the rects for this renderer only and add them to the results.
+ // Note that we could avoid passing the offset and instead adjust each result, but this
+ // seems slightly simpler.
+ Vector<LayoutRect> ownRects;
+ LayoutRect newContainerRect;
+ computeSelfHitTestRects(ownRects, layerOffset);
+
+ LayerHitTestRects::iterator iter = layerRects.find(currentLayer);
+ if (iter == layerRects.end())
+ iter = layerRects.add(currentLayer, Vector<LayoutRect>()).iterator;
+ for (size_t i = 0; i < ownRects.size(); i++) {
+ if (!containerRect.contains(ownRects[i])) {
+ iter->value.append(ownRects[i]);
+ if (newContainerRect.isEmpty())
+ newContainerRect = ownRects[i];
+ }
+ }
+ if (newContainerRect.isEmpty())
+ newContainerRect = containerRect;
+
// If it's possible for children to have rects outside our bounds, then we need to descend into
// the children and compute them.
// Ideally there would be other cases where we could detect that children couldn't have rects
@@ -2312,21 +2332,9 @@ void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const Ren
// rewrite Region to be more efficient. See https://bugs.webkit.org/show_bug.cgi?id=100814.
if (!isRenderView()) {
for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
- curr->addLayerHitTestRects(layerRects, currentLayer, layerOffset);
+ curr->addLayerHitTestRects(layerRects, currentLayer, layerOffset, newContainerRect);
}
}
-
- // Compute the rects for this renderer only and add them to the results.
- // Note that we could avoid passing the offset and instead adjust each result, but this
- // seems slightly simpler.
- Vector<LayoutRect> ownRects;
- computeSelfHitTestRects(ownRects, layerOffset);
-
- LayerHitTestRects::iterator iter = layerRects.find(currentLayer);
- if (iter == layerRects.end())
- layerRects.add(currentLayer, ownRects);
- else
- iter->value.append(ownRects);
}
bool RenderObject::isRooted(RenderView** view) const
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/RenderText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698