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

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: Fix git cl format mangling 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 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 { 1639 {
1640 FrameView* frameView = layoutObject->document().view(); 1640 FrameView* frameView = layoutObject->document().view();
1641 if (!frameView) 1641 if (!frameView)
1642 return LayoutRect(); 1642 return LayoutRect();
1643 1643
1644 return LayoutRect(frameView->visibleContentRect()); 1644 return LayoutRect(frameView->visibleContentRect());
1645 } 1645 }
1646 1646
1647 bool DeprecatedPaintLayer::hitTest(HitTestResult& result) 1647 bool DeprecatedPaintLayer::hitTest(HitTestResult& result)
1648 { 1648 {
1649 return hitTest(result.hitTestRequest(), result.hitTestLocation(), result);
1650 }
1651
1652 bool DeprecatedPaintLayer::hitTest(const HitTestRequest& request, const HitTestL ocation& hitTestLocation, HitTestResult& result)
1653 {
1654 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()); 1649 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
1655 1650
1656 // LayoutView should make sure to update layout before entering hit testing 1651 // LayoutView should make sure to update layout before entering hit testing
1657 ASSERT(!layoutObject()->frame()->view()->layoutPending()); 1652 ASSERT(!layoutObject()->frame()->view()->layoutPending());
1658 ASSERT(!layoutObject()->document().layoutView()->needsLayout()); 1653 ASSERT(!layoutObject()->document().layoutView()->needsLayout());
1659 1654
1655 const HitTestRequest& request = result.hitTestRequest();
1656 const HitTestLocation& hitTestLocation = result.hitTestLocation();
1657
1660 // Start with frameVisibleRect to ensure we include the scrollbars. 1658 // Start with frameVisibleRect to ensure we include the scrollbars.
1661 LayoutRect hitTestArea = frameVisibleRect(layoutObject()); 1659 LayoutRect hitTestArea = frameVisibleRect(layoutObject());
1662 if (request.ignoreClipping()) 1660 if (request.ignoreClipping())
1663 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect())); 1661 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect()));
1662 result.setValidityRect(boundingRect(hitTestLocation.point()));
1664 1663
1665 DeprecatedPaintLayer* insideLayer = hitTestLayer(this, 0, result, hitTestAre a, hitTestLocation, false); 1664 DeprecatedPaintLayer* insideLayer = hitTestLayer(this, 0, result, hitTestAre a, hitTestLocation, false);
1666 if (!insideLayer) { 1665 if (!insideLayer) {
1667 // We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down, 1666 // We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down,
1668 // return ourselves. We do this so mouse events continue getting deliver ed after a drag has 1667 // return ourselves. We do this so mouse events continue getting deliver ed after a drag has
1669 // exited the WebView, and so hit testing over a scrollbar hits the cont ent document. 1668 // exited the WebView, and so hit testing over a scrollbar hits the cont ent document.
1670 // In addtion, it is possible for the mouse to stay in the document but there is no element. 1669 // In addtion, it is possible for the mouse to stay in the document but there is no element.
1671 // At that time, the events of the mouse should be fired. 1670 // At that time, the events of the mouse should be fired.
1672 LayoutPoint hitPoint = hitTestLocation.point(); 1671 LayoutPoint hitPoint = hitTestLocation.point();
1673 if (!request.isChildFrameHitTest() && ((request.active() || request.rele ase()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && isRootLayer()) { 1672 if (!request.isChildFrameHitTest() && ((request.active() || request.rele ase()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && isRootLayer()) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 if (m_scrollableArea && m_scrollableArea->hitTestResizerInFragments(layerFra gments, hitTestLocation)) { 1888 if (m_scrollableArea && m_scrollableArea->hitTestResizerInFragments(layerFra gments, hitTestLocation)) {
1890 layoutObject()->updateHitTestResult(result, hitTestLocation.point()); 1889 layoutObject()->updateHitTestResult(result, hitTestLocation.point());
1891 return this; 1890 return this;
1892 } 1891 }
1893 1892
1894 // Next we want to see if the mouse pos is inside the child LayoutObjects of the layer. Check 1893 // Next we want to see if the mouse pos is inside the child LayoutObjects of the layer. Check
1895 // every fragment in reverse order. 1894 // every fragment in reverse order.
1896 if (isSelfPaintingLayer()) { 1895 if (isSelfPaintingLayer()) {
1897 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost. 1896 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost.
1898 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ()); 1897 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ());
1898 tempResult.setValidityRect(result.validityRect());
1899 bool insideFragmentForegroundRect = false; 1899 bool insideFragmentForegroundRect = false;
1900 if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocat ion, HitTestDescendants, insideFragmentForegroundRect) 1900 if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocat ion, HitTestDescendants, insideFragmentForegroundRect)
1901 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) { 1901 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) {
1902 if (result.hitTestRequest().listBased()) 1902 if (result.hitTestRequest().listBased())
1903 result.append(tempResult); 1903 result.append(tempResult);
1904 else 1904 else
1905 result = tempResult; 1905 result = tempResult;
1906 if (!depthSortDescendants) 1906 if (!depthSortDescendants)
1907 return this; 1907 return this;
1908 // Foreground can depth-sort with descendant layers, so keep this as a candidate. 1908 // Foreground can depth-sort with descendant layers, so keep this as a candidate.
(...skipping 11 matching lines...) Expand all
1920 return hitLayer; 1920 return hitLayer;
1921 candidateLayer = hitLayer; 1921 candidateLayer = hitLayer;
1922 } 1922 }
1923 1923
1924 // If we found a layer, return. Child layers, and foreground always render i n front of background. 1924 // If we found a layer, return. Child layers, and foreground always render i n front of background.
1925 if (candidateLayer) 1925 if (candidateLayer)
1926 return candidateLayer; 1926 return candidateLayer;
1927 1927
1928 if (isSelfPaintingLayer()) { 1928 if (isSelfPaintingLayer()) {
1929 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ()); 1929 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ());
1930 tempResult.setValidityRect(result.validityRect());
1930 bool insideFragmentBackgroundRect = false; 1931 bool insideFragmentBackgroundRect = false;
1931 if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocat ion, HitTestSelf, insideFragmentBackgroundRect) 1932 if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocat ion, HitTestSelf, insideFragmentBackgroundRect)
1932 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) { 1933 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) {
1933 if (result.isRectBasedTest()) 1934 if (result.isRectBasedTest())
1934 result.append(tempResult); 1935 result.append(tempResult);
1935 else 1936 else
1936 result = tempResult; 1937 result = tempResult;
1937 return this; 1938 return this;
1938 } 1939 }
1939 if (insideFragmentBackgroundRect && result.hitTestRequest().listBased()) 1940 if (insideFragmentBackgroundRect && result.hitTestRequest().listBased())
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 { 2075 {
2075 if (!hasSelfPaintingLayerDescendant()) 2076 if (!hasSelfPaintingLayerDescendant())
2076 return 0; 2077 return 0;
2077 2078
2078 DeprecatedPaintLayer* resultLayer = 0; 2079 DeprecatedPaintLayer* resultLayer = 0;
2079 DeprecatedPaintLayerStackingNodeReverseIterator iterator(*m_stackingNode, ch ildrentoVisit); 2080 DeprecatedPaintLayerStackingNodeReverseIterator iterator(*m_stackingNode, ch ildrentoVisit);
2080 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { 2081 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) {
2081 DeprecatedPaintLayer* childLayer = child->layer(); 2082 DeprecatedPaintLayer* childLayer = child->layer();
2082 DeprecatedPaintLayer* hitLayer = 0; 2083 DeprecatedPaintLayer* hitLayer = 0;
2083 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ()); 2084 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ());
2085 tempResult.setValidityRect(result.validityRect());
2084 if (childLayer->isPaginated()) 2086 if (childLayer->isPaginated())
2085 hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, tempRes ult, hitTestRect, hitTestLocation, transformState, zOffsetForDescendants); 2087 hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, tempRes ult, hitTestRect, hitTestLocation, transformState, zOffsetForDescendants);
2086 else 2088 else
2087 hitLayer = childLayer->hitTestLayer(rootLayer, this, tempResult, hit TestRect, hitTestLocation, false, transformState, zOffsetForDescendants); 2089 hitLayer = childLayer->hitTestLayer(rootLayer, this, tempResult, hit TestRect, hitTestLocation, false, transformState, zOffsetForDescendants);
2088 2090
2089 // If it is a list-based test, we can safely append the temporary result since it might had hit 2091 // If it is a list-based test, we can safely append the temporary result since it might had hit
2090 // nodes but not necesserily had hitLayer set. 2092 // nodes but not necesserily had hitLayer set.
2091 ASSERT(!result.isRectBasedTest() || result.hitTestRequest().listBased()) ; 2093 ASSERT(!result.isRectBasedTest() || result.hitTestRequest().listBased()) ;
2092 if (result.hitTestRequest().listBased()) 2094 if (result.hitTestRequest().listBased())
2093 result.append(tempResult); 2095 result.append(tempResult);
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
2965 2967
2966 void showLayerTree(const blink::LayoutObject* layoutObject) 2968 void showLayerTree(const blink::LayoutObject* layoutObject)
2967 { 2969 {
2968 if (!layoutObject) { 2970 if (!layoutObject) {
2969 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2971 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2970 return; 2972 return;
2971 } 2973 }
2972 showLayerTree(layoutObject->enclosingLayer()); 2974 showLayerTree(layoutObject->enclosingLayer());
2973 } 2975 }
2974 #endif 2976 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698