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

Side by Side Diff: Source/core/rendering/RenderLayer.cpp

Issue 869813003: Implement elementsFromPoint (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix typeo Created 5 years, 11 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 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 1875
1876 // Collect the fragments. This will compute the clip rectangles for each lay er fragment. 1876 // Collect the fragments. This will compute the clip rectangles for each lay er fragment.
1877 LayerFragments layerFragments; 1877 LayerFragments layerFragments;
1878 collectFragments(layerFragments, rootLayer, hitTestRect, RootRelativeClipRec ts, IncludeOverlayScrollbarSize); 1878 collectFragments(layerFragments, rootLayer, hitTestRect, RootRelativeClipRec ts, IncludeOverlayScrollbarSize);
1879 1879
1880 if (m_scrollableArea && m_scrollableArea->hitTestResizerInFragments(layerFra gments, hitTestLocation)) { 1880 if (m_scrollableArea && m_scrollableArea->hitTestResizerInFragments(layerFra gments, hitTestLocation)) {
1881 renderer()->updateHitTestResult(result, hitTestLocation.point()); 1881 renderer()->updateHitTestResult(result, hitTestLocation.point());
1882 return this; 1882 return this;
1883 } 1883 }
1884 1884
1885 ASSERT(!result.isRectBasedTest() || request.listBased());
Rick Byers 2015/02/04 10:34:03 Asserts like this can probably move into HitTestRe
pdr. 2015/02/17 04:10:14 Done.
pdr. 2015/02/17 04:10:14 Done.
1886
1885 // Next we want to see if the mouse pos is inside the child RenderObjects of the layer. Check 1887 // Next we want to see if the mouse pos is inside the child RenderObjects of the layer. Check
1886 // every fragment in reverse order. 1888 // every fragment in reverse order.
1887 if (isSelfPaintingLayer()) { 1889 if (isSelfPaintingLayer()) {
1888 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost. 1890 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost.
1889 HitTestResult tempResult(result.hitTestLocation()); 1891 HitTestResult tempResult(result.hitTestLocation());
1890 bool insideFragmentForegroundRect = false; 1892 bool insideFragmentForegroundRect = false;
1891 if (hitTestContentsForFragments(layerFragments, request, tempResult, hit TestLocation, HitTestDescendants, insideFragmentForegroundRect) 1893 if (hitTestContentsForFragments(layerFragments, request, tempResult, hit TestLocation, HitTestDescendants, insideFragmentForegroundRect)
1892 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) { 1894 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) {
1893 if (result.isRectBasedTest()) 1895 if (request.listBased())
1894 result.append(tempResult); 1896 result.append(tempResult);
1895 else 1897 else
1896 result = tempResult; 1898 result = tempResult;
1897 if (!depthSortDescendants) 1899 if (!depthSortDescendants)
1898 return this; 1900 return this;
1899 // Foreground can depth-sort with descendant layers, so keep this as a candidate. 1901 // Foreground can depth-sort with descendant layers, so keep this as a candidate.
1900 candidateLayer = this; 1902 candidateLayer = this;
1901 } else if (insideFragmentForegroundRect && result.isRectBasedTest()) 1903 } else if (insideFragmentForegroundRect && request.listBased())
1902 result.append(tempResult); 1904 result.append(tempResult);
1903 } 1905 }
1904 1906
1905 // Now check our negative z-index children. 1907 // Now check our negative z-index children.
1906 hitLayer = hitTestChildren(NegativeZOrderChildren, rootLayer, request, resul t, hitTestRect, hitTestLocation, 1908 hitLayer = hitTestChildren(NegativeZOrderChildren, rootLayer, request, resul t, hitTestRect, hitTestLocation,
1907 localTransformState.get(), zOffsetForDescendantsPtr, zOffset, unflattene dTransformState.get(), depthSortDescendants); 1909 localTransformState.get(), zOffsetForDescendantsPtr, zOffset, unflattene dTransformState.get(), depthSortDescendants);
1908 if (hitLayer) { 1910 if (hitLayer) {
1909 if (!depthSortDescendants) 1911 if (!depthSortDescendants)
1910 return hitLayer; 1912 return hitLayer;
1911 candidateLayer = hitLayer; 1913 candidateLayer = hitLayer;
1912 } 1914 }
1913 1915
1914 // If we found a layer, return. Child layers, and foreground always render i n front of background. 1916 // If we found a layer, return. Child layers, and foreground always render i n front of background.
1915 if (candidateLayer) 1917 if (candidateLayer)
1916 return candidateLayer; 1918 return candidateLayer;
1917 1919
1918 if (isSelfPaintingLayer()) { 1920 if (isSelfPaintingLayer()) {
1919 HitTestResult tempResult(result.hitTestLocation()); 1921 HitTestResult tempResult(result.hitTestLocation());
1920 bool insideFragmentBackgroundRect = false; 1922 bool insideFragmentBackgroundRect = false;
1921 if (hitTestContentsForFragments(layerFragments, request, tempResult, hit TestLocation, HitTestSelf, insideFragmentBackgroundRect) 1923 if (hitTestContentsForFragments(layerFragments, request, tempResult, hit TestLocation, HitTestSelf, insideFragmentBackgroundRect)
1922 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) { 1924 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) {
1923 if (result.isRectBasedTest()) 1925 if (request.listBased())
1924 result.append(tempResult); 1926 result.append(tempResult);
1925 else 1927 else
1926 result = tempResult; 1928 result = tempResult;
1927 return this; 1929 return this;
1928 } 1930 }
1929 if (insideFragmentBackgroundRect && result.isRectBasedTest()) 1931 if (insideFragmentBackgroundRect && request.listBased())
1930 result.append(tempResult); 1932 result.append(tempResult);
1931 } 1933 }
1932 1934
1933 return 0; 1935 return 0;
1934 } 1936 }
1935 1937
1936 bool RenderLayer::hitTestContentsForFragments(const LayerFragments& layerFragmen ts, const HitTestRequest& request, HitTestResult& result, 1938 bool RenderLayer::hitTestContentsForFragments(const LayerFragments& layerFragmen ts, const HitTestRequest& request, HitTestResult& result,
1937 const HitTestLocation& hitTestLocation, HitTestFilter hitTestFilter, bool& i nsideClipRect) const 1939 const HitTestLocation& hitTestLocation, HitTestFilter hitTestFilter, bool& i nsideClipRect) const
1938 { 1940 {
1939 if (layerFragments.isEmpty()) 1941 if (layerFragments.isEmpty())
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 return hitTestLayer(this, containerLayer, request, result, localHitTestRect, newHitTestLocation, true, newTransformState.get(), zOffset); 2021 return hitTestLayer(this, containerLayer, request, result, localHitTestRect, newHitTestLocation, true, newTransformState.get(), zOffset);
2020 } 2022 }
2021 2023
2022 bool RenderLayer::hitTestContents(const HitTestRequest& request, HitTestResult& result, const LayoutRect& layerBounds, const HitTestLocation& hitTestLocation, H itTestFilter hitTestFilter) const 2024 bool RenderLayer::hitTestContents(const HitTestRequest& request, HitTestResult& result, const LayoutRect& layerBounds, const HitTestLocation& hitTestLocation, H itTestFilter hitTestFilter) const
2023 { 2025 {
2024 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()); 2026 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
2025 2027
2026 if (!renderer()->hitTest(request, result, hitTestLocation, toLayoutPoint(lay erBounds.location() - renderBoxLocation()), hitTestFilter)) { 2028 if (!renderer()->hitTest(request, result, hitTestLocation, toLayoutPoint(lay erBounds.location() - renderBoxLocation()), hitTestFilter)) {
2027 // It's wrong to set innerNode, but then claim that you didn't hit anyth ing, unless it is 2029 // It's wrong to set innerNode, but then claim that you didn't hit anyth ing, unless it is
2028 // a rect-based test. 2030 // a rect-based test.
2029 ASSERT(!result.innerNode() || (result.isRectBasedTest() && result.rectBa sedTestResult().size())); 2031 ASSERT(!result.innerNode() || (request.listBased() && result.listBasedTe stResult().size()));
2030 return false; 2032 return false;
2031 } 2033 }
2032 2034
2033 // For positioned generated content, we might still not have a 2035 // For positioned generated content, we might still not have a
2034 // node by the time we get to the layer level, since none of 2036 // node by the time we get to the layer level, since none of
2035 // the content in the layer has an element. So just walk up 2037 // the content in the layer has an element. So just walk up
2036 // the tree. 2038 // the tree.
2037 if (!result.innerNode() || !result.innerNonSharedNode()) { 2039 if (!result.innerNode() || !result.innerNonSharedNode()) {
2038 Node* e = enclosingElement(); 2040 Node* e = enclosingElement();
2039 if (!result.innerNode()) 2041 if (!result.innerNode())
(...skipping 20 matching lines...) Expand all
2060 RenderLayerStackingNodeReverseIterator iterator(*m_stackingNode, childrentoV isit); 2062 RenderLayerStackingNodeReverseIterator iterator(*m_stackingNode, childrentoV isit);
2061 while (RenderLayerStackingNode* child = iterator.next()) { 2063 while (RenderLayerStackingNode* child = iterator.next()) {
2062 RenderLayer* childLayer = child->layer(); 2064 RenderLayer* childLayer = child->layer();
2063 RenderLayer* hitLayer = 0; 2065 RenderLayer* hitLayer = 0;
2064 HitTestResult tempResult(result.hitTestLocation()); 2066 HitTestResult tempResult(result.hitTestLocation());
2065 if (childLayer->isPaginated()) 2067 if (childLayer->isPaginated())
2066 hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, request , tempResult, hitTestRect, hitTestLocation, transformState, zOffsetForDescendant s); 2068 hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, request , tempResult, hitTestRect, hitTestLocation, transformState, zOffsetForDescendant s);
2067 else 2069 else
2068 hitLayer = childLayer->hitTestLayer(rootLayer, this, request, tempRe sult, hitTestRect, hitTestLocation, false, transformState, zOffsetForDescendants ); 2070 hitLayer = childLayer->hitTestLayer(rootLayer, this, request, tempRe sult, hitTestRect, hitTestLocation, false, transformState, zOffsetForDescendants );
2069 2071
2070 // If it a rect-based test, we can safely append the temporary result si nce it might had hit 2072 // If it a list-based test, we can safely append the temporary result si nce it might had hit
Rick Byers 2015/02/04 10:34:03 nit: s/it/it is/
pdr. 2015/02/17 04:10:14 Done.
2071 // nodes but not necesserily had hitLayer set. 2073 // nodes but not necesserily had hitLayer set.
2072 if (result.isRectBasedTest()) 2074 ASSERT(!result.isRectBasedTest() || request.listBased());
2075 if (request.listBased())
2073 result.append(tempResult); 2076 result.append(tempResult);
2074 2077
2075 if (isHitCandidate(hitLayer, depthSortDescendants, zOffset, unflattenedT ransformState)) { 2078 if (isHitCandidate(hitLayer, depthSortDescendants, zOffset, unflattenedT ransformState)) {
2076 resultLayer = hitLayer; 2079 resultLayer = hitLayer;
2077 if (!result.isRectBasedTest()) 2080 if (!request.listBased())
2078 result = tempResult; 2081 result = tempResult;
2079 if (!depthSortDescendants) 2082 if (!depthSortDescendants)
2080 break; 2083 break;
2081 } 2084 }
2082 } 2085 }
2083 2086
2084 return resultLayer; 2087 return resultLayer;
2085 } 2088 }
2086 2089
2087 RenderLayer* RenderLayer::hitTestPaginatedChildLayer(RenderLayer* childLayer, Re nderLayer* rootLayer, const HitTestRequest& request, HitTestResult& result, 2090 RenderLayer* RenderLayer::hitTestPaginatedChildLayer(RenderLayer* childLayer, Re nderLayer* rootLayer, const HitTestRequest& request, HitTestResult& result,
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
2926 } 2929 }
2927 } 2930 }
2928 2931
2929 void showLayerTree(const blink::RenderObject* renderer) 2932 void showLayerTree(const blink::RenderObject* renderer)
2930 { 2933 {
2931 if (!renderer) 2934 if (!renderer)
2932 return; 2935 return;
2933 showLayerTree(renderer->enclosingLayer()); 2936 showLayerTree(renderer->enclosingLayer());
2934 } 2937 }
2935 #endif 2938 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698