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

Side by Side Diff: Source/core/paint/DeprecatedPaintLayerStackingNode.cpp

Issue 1142283004: Implement a Hit Test Cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix comments from tdresser Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 return LayoutRect(frameView->visibleContentRect()); 333 return LayoutRect(frameView->visibleContentRect());
334 } 334 }
335 335
336 LayoutBoxModelObject* DeprecatedPaintLayerStackingNode::layoutObject() const 336 LayoutBoxModelObject* DeprecatedPaintLayerStackingNode::layoutObject() const
337 { 337 {
338 return m_layer->layoutObject(); 338 return m_layer->layoutObject();
339 } 339 }
340 340
341 bool DeprecatedPaintLayerStackingNode::hitTest(HitTestResult& result) 341 bool DeprecatedPaintLayerStackingNode::hitTest(HitTestResult& result)
342 { 342 {
343 return hitTest(result.hitTestRequest(), result.hitTestLocation(), result);
344 }
345
346 bool DeprecatedPaintLayerStackingNode::hitTest(const HitTestRequest& request, co nst HitTestLocation& hitTestLocation, HitTestResult& result)
347 {
348 ASSERT(layer()->isSelfPaintingLayer() || layer()->hasSelfPaintingLayerDescen dant()); 343 ASSERT(layer()->isSelfPaintingLayer() || layer()->hasSelfPaintingLayerDescen dant());
349 344
350 // LayoutView should make sure to update layout before entering hit testing 345 // LayoutView should make sure to update layout before entering hit testing
351 ASSERT(!layoutObject()->frame()->view()->layoutPending()); 346 ASSERT(!layoutObject()->frame()->view()->layoutPending());
352 ASSERT(!layoutObject()->document().layoutView()->needsLayout()); 347 ASSERT(!layoutObject()->document().layoutView()->needsLayout());
353 348
349 const HitTestRequest& request = result.hitTestRequest();
350 const HitTestLocation& hitTestLocation = result.hitTestLocation();
351
354 // Start with frameVisibleRect to ensure we include the scrollbars. 352 // Start with frameVisibleRect to ensure we include the scrollbars.
355 LayoutRect hitTestArea = frameVisibleRect(layoutObject()); 353 LayoutRect hitTestArea = frameVisibleRect(layoutObject());
356 if (request.ignoreClipping()) 354 if (request.ignoreClipping())
357 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect())); 355 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect()));
356 result.setValidityRect(boundingRect(hitTestLocation.point()));
358 357
359 DeprecatedPaintLayer* insideLayer = layer()->hitTestLayer(layer(), 0, result , hitTestArea, hitTestLocation, false); 358 DeprecatedPaintLayer* insideLayer = layer()->hitTestLayer(layer(), 0, result , hitTestArea, hitTestLocation, false);
360 if (!insideLayer) { 359 if (!insideLayer) {
361 // We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down, 360 // We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down,
362 // return ourselves. We do this so mouse events continue getting deliver ed after a drag has 361 // return ourselves. We do this so mouse events continue getting deliver ed after a drag has
363 // exited the WebView, and so hit testing over a scrollbar hits the cont ent document. 362 // exited the WebView, and so hit testing over a scrollbar hits the cont ent document.
364 // In addtion, it is possible for the mouse to stay in the document but there is no element. 363 // In addtion, it is possible for the mouse to stay in the document but there is no element.
365 // At that time, the events of the mouse should be fired. 364 // At that time, the events of the mouse should be fired.
366 LayoutPoint hitPoint = hitTestLocation.point(); 365 LayoutPoint hitPoint = hitTestLocation.point();
367 if (!request.isChildFrameHitTest() && ((request.active() || request.rele ase()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && layer()->isRootLayer()) { 366 if (!request.isChildFrameHitTest() && ((request.active() || request.rele ase()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && layer()->isRootLayer()) {
368 layoutObject()->updateHitTestResult(result, toLayoutView(layoutObjec t())->flipForWritingMode(hitTestLocation.point())); 367 layoutObject()->updateHitTestResult(result, toLayoutView(layoutObjec t())->flipForWritingMode(hitTestLocation.point()));
369 insideLayer = layer(); 368 insideLayer = layer();
370 } 369 }
371 } 370 }
372 371
373 // Now determine if the result is inside an anchor - if the urlElement isn't already set. 372 // Now determine if the result is inside an anchor - if the urlElement isn't already set.
374 Node* node = result.innerNode(); 373 Node* node = result.innerNode();
375 if (node && !result.URLElement()) 374 if (node && !result.URLElement())
376 result.setURLElement(node->enclosingLinkEventParentOrSelf()); 375 result.setURLElement(node->enclosingLinkEventParentOrSelf());
377 376
378 // Now return whether we were inside this layer (this will always be true fo r the root 377 // Now return whether we were inside this layer (this will always be true fo r the root
379 // layer). 378 // layer).
380 return insideLayer; 379 return insideLayer;
381 } 380 }
382 381
383 } // namespace blink 382 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698