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

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

Issue 1177123003: Revert "Implement a Hit Test Cache for same point hits." (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 {
1583 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()); 1588 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
1584 1589
1585 // LayoutView should make sure to update layout before entering hit testing 1590 // LayoutView should make sure to update layout before entering hit testing
1586 ASSERT(!layoutObject()->frame()->view()->layoutPending()); 1591 ASSERT(!layoutObject()->frame()->view()->layoutPending());
1587 ASSERT(!layoutObject()->document().layoutView()->needsLayout()); 1592 ASSERT(!layoutObject()->document().layoutView()->needsLayout());
1588 1593
1589 const HitTestRequest& request = result.hitTestRequest();
1590 const HitTestLocation& hitTestLocation = result.hitTestLocation();
1591
1592 // Start with frameVisibleRect to ensure we include the scrollbars. 1594 // Start with frameVisibleRect to ensure we include the scrollbars.
1593 LayoutRect hitTestArea = frameVisibleRect(layoutObject()); 1595 LayoutRect hitTestArea = frameVisibleRect(layoutObject());
1594 if (request.ignoreClipping()) 1596 if (request.ignoreClipping())
1595 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect())); 1597 hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect()));
1596 result.setValidityRect(boundingRect(hitTestLocation.point()));
1597 1598
1598 DeprecatedPaintLayer* insideLayer = hitTestLayer(this, 0, result, hitTestAre a, hitTestLocation, false); 1599 DeprecatedPaintLayer* insideLayer = hitTestLayer(this, 0, result, hitTestAre a, hitTestLocation, false);
1599 if (!insideLayer) { 1600 if (!insideLayer) {
1600 // We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down, 1601 // We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down,
1601 // return ourselves. We do this so mouse events continue getting deliver ed after a drag has 1602 // return ourselves. We do this so mouse events continue getting deliver ed after a drag has
1602 // exited the WebView, and so hit testing over a scrollbar hits the cont ent document. 1603 // exited the WebView, and so hit testing over a scrollbar hits the cont ent document.
1603 // In addtion, it is possible for the mouse to stay in the document but there is no element. 1604 // In addtion, it is possible for the mouse to stay in the document but there is no element.
1604 // At that time, the events of the mouse should be fired. 1605 // At that time, the events of the mouse should be fired.
1605 LayoutPoint hitPoint = hitTestLocation.point(); 1606 LayoutPoint hitPoint = hitTestLocation.point();
1606 if (!request.isChildFrameHitTest() && ((request.active() || request.rele ase()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && isRootLayer()) { 1607 if (!request.isChildFrameHitTest() && ((request.active() || request.rele ase()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && isRootLayer()) {
1607 layoutObject()->updateHitTestResult(result, toLayoutView(layoutObjec t())->flipForWritingMode(hitTestLocation.point())); 1608 layoutObject()->updateHitTestResult(result, toLayoutView(layoutObjec t())->flipForWritingMode(hitTestLocation.point()));
1608 insideLayer = this; 1609 insideLayer = this;
1609
1610 // Don't cache this result since it really wasn't a true hit.
1611 result.setValidityRect(LayoutRect());
1612 } 1610 }
1613 } 1611 }
1614 1612
1615 // Now determine if the result is inside an anchor - if the urlElement isn't already set. 1613 // Now determine if the result is inside an anchor - if the urlElement isn't already set.
1616 Node* node = result.innerNode(); 1614 Node* node = result.innerNode();
1617 if (node && !result.URLElement()) 1615 if (node && !result.URLElement())
1618 result.setURLElement(node->enclosingLinkEventParentOrSelf()); 1616 result.setURLElement(node->enclosingLinkEventParentOrSelf());
1619 1617
1620 // Now return whether we were inside this layer (this will always be true fo r the root 1618 // Now return whether we were inside this layer (this will always be true fo r the root
1621 // layer). 1619 // layer).
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 if (m_scrollableArea && m_scrollableArea->hitTestResizerInFragments(layerFra gments, hitTestLocation)) { 1823 if (m_scrollableArea && m_scrollableArea->hitTestResizerInFragments(layerFra gments, hitTestLocation)) {
1826 layoutObject()->updateHitTestResult(result, hitTestLocation.point()); 1824 layoutObject()->updateHitTestResult(result, hitTestLocation.point());
1827 return this; 1825 return this;
1828 } 1826 }
1829 1827
1830 // Next we want to see if the mouse pos is inside the child LayoutObjects of the layer. Check 1828 // Next we want to see if the mouse pos is inside the child LayoutObjects of the layer. Check
1831 // every fragment in reverse order. 1829 // every fragment in reverse order.
1832 if (isSelfPaintingLayer()) { 1830 if (isSelfPaintingLayer()) {
1833 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost. 1831 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost.
1834 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ()); 1832 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ());
1835 tempResult.setValidityRect(result.validityRect());
1836 bool insideFragmentForegroundRect = false; 1833 bool insideFragmentForegroundRect = false;
1837 if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocat ion, HitTestDescendants, insideFragmentForegroundRect) 1834 if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocat ion, HitTestDescendants, insideFragmentForegroundRect)
1838 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) { 1835 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) {
1839 if (result.hitTestRequest().listBased()) 1836 if (result.hitTestRequest().listBased())
1840 result.append(tempResult); 1837 result.append(tempResult);
1841 else 1838 else
1842 result = tempResult; 1839 result = tempResult;
1843 if (!depthSortDescendants) 1840 if (!depthSortDescendants)
1844 return this; 1841 return this;
1845 // Foreground can depth-sort with descendant layers, so keep this as a candidate. 1842 // Foreground can depth-sort with descendant layers, so keep this as a candidate.
(...skipping 11 matching lines...) Expand all
1857 return hitLayer; 1854 return hitLayer;
1858 candidateLayer = hitLayer; 1855 candidateLayer = hitLayer;
1859 } 1856 }
1860 1857
1861 // If we found a layer, return. Child layers, and foreground always render i n front of background. 1858 // If we found a layer, return. Child layers, and foreground always render i n front of background.
1862 if (candidateLayer) 1859 if (candidateLayer)
1863 return candidateLayer; 1860 return candidateLayer;
1864 1861
1865 if (isSelfPaintingLayer()) { 1862 if (isSelfPaintingLayer()) {
1866 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ()); 1863 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ());
1867 tempResult.setValidityRect(result.validityRect());
1868 bool insideFragmentBackgroundRect = false; 1864 bool insideFragmentBackgroundRect = false;
1869 if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocat ion, HitTestSelf, insideFragmentBackgroundRect) 1865 if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocat ion, HitTestSelf, insideFragmentBackgroundRect)
1870 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) { 1866 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) {
1871 if (result.isRectBasedTest()) 1867 if (result.isRectBasedTest())
1872 result.append(tempResult); 1868 result.append(tempResult);
1873 else 1869 else
1874 result = tempResult; 1870 result = tempResult;
1875 return this; 1871 return this;
1876 } 1872 }
1877 if (insideFragmentBackgroundRect && result.hitTestRequest().listBased()) 1873 if (insideFragmentBackgroundRect && result.hitTestRequest().listBased())
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 { 2008 {
2013 if (!hasSelfPaintingLayerDescendant()) 2009 if (!hasSelfPaintingLayerDescendant())
2014 return 0; 2010 return 0;
2015 2011
2016 DeprecatedPaintLayer* resultLayer = 0; 2012 DeprecatedPaintLayer* resultLayer = 0;
2017 DeprecatedPaintLayerStackingNodeReverseIterator iterator(*m_stackingNode, ch ildrentoVisit); 2013 DeprecatedPaintLayerStackingNodeReverseIterator iterator(*m_stackingNode, ch ildrentoVisit);
2018 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { 2014 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) {
2019 DeprecatedPaintLayer* childLayer = child->layer(); 2015 DeprecatedPaintLayer* childLayer = child->layer();
2020 DeprecatedPaintLayer* hitLayer = 0; 2016 DeprecatedPaintLayer* hitLayer = 0;
2021 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ()); 2017 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation ());
2022 tempResult.setValidityRect(result.validityRect());
2023 hitLayer = childLayer->hitTestLayer(rootLayer, this, tempResult, hitTest Rect, hitTestLocation, false, transformState, zOffsetForDescendants); 2018 hitLayer = childLayer->hitTestLayer(rootLayer, this, tempResult, hitTest Rect, hitTestLocation, false, transformState, zOffsetForDescendants);
2024 2019
2025 // If it is a list-based test, we can safely append the temporary result since it might had hit 2020 // If it is a list-based test, we can safely append the temporary result since it might had hit
2026 // nodes but not necesserily had hitLayer set. 2021 // nodes but not necesserily had hitLayer set.
2027 ASSERT(!result.isRectBasedTest() || result.hitTestRequest().listBased()) ; 2022 ASSERT(!result.isRectBasedTest() || result.hitTestRequest().listBased()) ;
2028 if (result.hitTestRequest().listBased()) 2023 if (result.hitTestRequest().listBased())
2029 result.append(tempResult); 2024 result.append(tempResult);
2030 2025
2031 if (isHitCandidate(hitLayer, depthSortDescendants, zOffset, unflattenedT ransformState)) { 2026 if (isHitCandidate(hitLayer, depthSortDescendants, zOffset, unflattenedT ransformState)) {
2032 resultLayer = hitLayer; 2027 resultLayer = hitLayer;
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
2768 2763
2769 void showLayerTree(const blink::LayoutObject* layoutObject) 2764 void showLayerTree(const blink::LayoutObject* layoutObject)
2770 { 2765 {
2771 if (!layoutObject) { 2766 if (!layoutObject) {
2772 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2767 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2773 return; 2768 return;
2774 } 2769 }
2775 showLayerTree(layoutObject->enclosingLayer()); 2770 showLayerTree(layoutObject->enclosingLayer());
2776 } 2771 }
2777 #endif 2772 #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