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

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

Issue 1142283004: Implement a Hit Test Cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove validity rect as per Elliott's request 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 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 { 1573 {
1574 FrameView* frameView = layoutObject->document().view(); 1574 FrameView* frameView = layoutObject->document().view();
1575 if (!frameView) 1575 if (!frameView)
1576 return LayoutRect(); 1576 return LayoutRect();
1577 1577
1578 return LayoutRect(frameView->visibleContentRect()); 1578 return LayoutRect(frameView->visibleContentRect());
1579 } 1579 }
1580 1580
1581 bool DeprecatedPaintLayer::hitTest(HitTestResult& result) 1581 bool DeprecatedPaintLayer::hitTest(HitTestResult& result)
1582 { 1582 {
1583 return hitTest(result.hitTestRequest(), result.hitTestLocation(), result);
1584 }
1585
1586 bool DeprecatedPaintLayer::hitTest(const HitTestRequest& request, const HitTestL ocation& hitTestLocation, HitTestResult& result)
1587 {
1588 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()); 1583 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
1589 1584
1590 // LayoutView should make sure to update layout before entering hit testing 1585 // LayoutView should make sure to update layout before entering hit testing
1591 ASSERT(!layoutObject()->frame()->view()->layoutPending()); 1586 ASSERT(!layoutObject()->frame()->view()->layoutPending());
1592 ASSERT(!layoutObject()->document().layoutView()->needsLayout()); 1587 ASSERT(!layoutObject()->document().layoutView()->needsLayout());
1593 1588
1589 const HitTestRequest& request = result.hitTestRequest();
1590 const HitTestLocation& hitTestLocation = result.hitTestLocation();
1591
1594 // Start with frameVisibleRect to ensure we include the scrollbars. 1592 // Start with frameVisibleRect to ensure we include the scrollbars.
1595 LayoutRect hitTestArea = frameVisibleRect(layoutObject()); 1593 LayoutRect hitTestArea = frameVisibleRect(layoutObject());
1596 if (request.ignoreClipping()) 1594 if (request.ignoreClipping())
1597 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect())); 1595 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect()));
1598 1596
1599 DeprecatedPaintLayer* insideLayer = hitTestLayer(this, 0, result, hitTestAre a, hitTestLocation, false); 1597 DeprecatedPaintLayer* insideLayer = hitTestLayer(this, 0, result, hitTestAre a, hitTestLocation, false);
1600 if (!insideLayer) { 1598 if (!insideLayer) {
1601 // We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down, 1599 // We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down,
1602 // return ourselves. We do this so mouse events continue getting deliver ed after a drag has 1600 // return ourselves. We do this so mouse events continue getting deliver ed after a drag has
1603 // exited the WebView, and so hit testing over a scrollbar hits the cont ent document. 1601 // exited the WebView, and so hit testing over a scrollbar hits the cont ent document.
1604 // In addtion, it is possible for the mouse to stay in the document but there is no element. 1602 // In addtion, it is possible for the mouse to stay in the document but there is no element.
1605 // At that time, the events of the mouse should be fired. 1603 // At that time, the events of the mouse should be fired.
1606 LayoutPoint hitPoint = hitTestLocation.point(); 1604 LayoutPoint hitPoint = hitTestLocation.point();
1607 if (!request.isChildFrameHitTest() && ((request.active() || request.rele ase()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && isRootLayer()) { 1605 if (!request.isChildFrameHitTest() && ((request.active() || request.rele ase()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && isRootLayer()) {
1608 layoutObject()->updateHitTestResult(result, toLayoutView(layoutObjec t())->flipForWritingMode(hitTestLocation.point())); 1606 layoutObject()->updateHitTestResult(result, toLayoutView(layoutObjec t())->flipForWritingMode(hitTestLocation.point()));
1609 insideLayer = this; 1607 insideLayer = this;
1608
1609 // Don't cache this result since it really wasn't a true hit.
1610 result.setCacheable(false);
1610 } 1611 }
1611 } 1612 }
1612 1613
1613 // Now determine if the result is inside an anchor - if the urlElement isn't already set. 1614 // Now determine if the result is inside an anchor - if the urlElement isn't already set.
1614 Node* node = result.innerNode(); 1615 Node* node = result.innerNode();
1615 if (node && !result.URLElement()) 1616 if (node && !result.URLElement())
1616 result.setURLElement(node->enclosingLinkEventParentOrSelf()); 1617 result.setURLElement(node->enclosingLinkEventParentOrSelf());
1617 1618
1618 // Now return whether we were inside this layer (this will always be true fo r the root 1619 // Now return whether we were inside this layer (this will always be true fo r the root
1619 // layer). 1620 // layer).
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 2764
2764 void showLayerTree(const blink::LayoutObject* layoutObject) 2765 void showLayerTree(const blink::LayoutObject* layoutObject)
2765 { 2766 {
2766 if (!layoutObject) { 2767 if (!layoutObject) {
2767 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2768 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2768 return; 2769 return;
2769 } 2770 }
2770 showLayerTree(layoutObject->enclosingLayer()); 2771 showLayerTree(layoutObject->enclosingLayer());
2771 } 2772 }
2772 #endif 2773 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutView.cpp ('k') | Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698