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

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

Issue 17471008: Rework compositor touch hit testing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: CR feedback - accumulate LayoutRects instead of IntRects, disable when page isn't composited. Also… 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 e32235b88474d3c23ae76b02079eeb5c46e0066c..5476edf4ba7da6925a0ca10bde9daf9f38e92f98 100644
--- a/Source/core/rendering/RenderObject.cpp
+++ b/Source/core/rendering/RenderObject.cpp
@@ -2271,6 +2271,60 @@ LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthT
return LayoutRect();
}
+void RenderObject::computeLayerHitTestRects(LayerHitTestRects& layerRects) const
+{
+ // Figure out what layer our container is in. Any offset (or new layer) for this
+ // renderer within it's container will be applied in addLayerHitTestRects.
+ LayoutPoint layerOffset;
+ const RenderLayer* currentLayer = 0;
+
+ if (!hasLayer()) {
+ RenderObject* container = this->container();
+ if (container) {
+ currentLayer = container->enclosingLayer();
+ if (currentLayer && currentLayer->renderer() != container)
+ layerOffset.move(container->offsetFromAncestorContainer(currentLayer->renderer()));
+ } else {
+ currentLayer = enclosingLayer();
+ }
+ if (!currentLayer)
+ return;
+ }
+
+ this->addLayerHitTestRects(layerRects, currentLayer, layerOffset);
+}
+
+void RenderObject::addLayerHitTestRects(LayerHitTestRects& layerRects, const RenderLayer* currentLayer, const LayoutPoint& layerOffset) const
+{
+ ASSERT(currentLayer);
+ ASSERT(currentLayer == this->enclosingLayer());
+
+ // 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
+ // outside our bounds and prune the tree walk.
+ // Note that we don't use Region here because Union is O(N) - better to just keep a list of
+ // partially redundant rectangles. If we find examples where this is expensive, then we could
+ // 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);
+ }
+ }
+
+ // 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
{
const RenderObject* o = this;
« 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