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

Side by Side Diff: Source/core/layout/Layer.cpp

Issue 869813003: Implement elementsFromPoint (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Cleanup, add a better test for tables Created 5 years, 10 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
« no previous file with comments | « Source/core/layout/HitTestResult.cpp ('k') | Source/core/layout/LayoutImage.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 } 1900 }
1901 1901
1902 // Next we want to see if the mouse pos is inside the child LayoutObjects of the layer. Check 1902 // Next we want to see if the mouse pos is inside the child LayoutObjects of the layer. Check
1903 // every fragment in reverse order. 1903 // every fragment in reverse order.
1904 if (isSelfPaintingLayer()) { 1904 if (isSelfPaintingLayer()) {
1905 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost. 1905 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost.
1906 HitTestResult tempResult(result.hitTestLocation()); 1906 HitTestResult tempResult(result.hitTestLocation());
1907 bool insideFragmentForegroundRect = false; 1907 bool insideFragmentForegroundRect = false;
1908 if (hitTestContentsForFragments(layerFragments, request, tempResult, hit TestLocation, HitTestDescendants, insideFragmentForegroundRect) 1908 if (hitTestContentsForFragments(layerFragments, request, tempResult, hit TestLocation, HitTestDescendants, insideFragmentForegroundRect)
1909 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) { 1909 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) {
1910 if (result.isRectBasedTest()) 1910 if (request.listBased())
1911 result.append(tempResult); 1911 result.append(tempResult, request);
1912 else 1912 else
1913 result = tempResult; 1913 result = tempResult;
1914 if (!depthSortDescendants) 1914 if (!depthSortDescendants)
1915 return this; 1915 return this;
1916 // Foreground can depth-sort with descendant layers, so keep this as a candidate. 1916 // Foreground can depth-sort with descendant layers, so keep this as a candidate.
1917 candidateLayer = this; 1917 candidateLayer = this;
1918 } else if (insideFragmentForegroundRect && result.isRectBasedTest()) { 1918 } else if (insideFragmentForegroundRect && request.listBased()) {
1919 result.append(tempResult); 1919 result.append(tempResult, request);
1920 } 1920 }
1921 } 1921 }
1922 1922
1923 // Now check our negative z-index children. 1923 // Now check our negative z-index children.
1924 hitLayer = hitTestChildren(NegativeZOrderChildren, rootLayer, request, resul t, hitTestRect, hitTestLocation, 1924 hitLayer = hitTestChildren(NegativeZOrderChildren, rootLayer, request, resul t, hitTestRect, hitTestLocation,
1925 localTransformState.get(), zOffsetForDescendantsPtr, zOffset, unflattene dTransformState.get(), depthSortDescendants); 1925 localTransformState.get(), zOffsetForDescendantsPtr, zOffset, unflattene dTransformState.get(), depthSortDescendants);
1926 if (hitLayer) { 1926 if (hitLayer) {
1927 if (!depthSortDescendants) 1927 if (!depthSortDescendants)
1928 return hitLayer; 1928 return hitLayer;
1929 candidateLayer = hitLayer; 1929 candidateLayer = hitLayer;
1930 } 1930 }
1931 1931
1932 // If we found a layer, return. Child layers, and foreground always render i n front of background. 1932 // If we found a layer, return. Child layers, and foreground always render i n front of background.
1933 if (candidateLayer) 1933 if (candidateLayer)
1934 return candidateLayer; 1934 return candidateLayer;
1935 1935
1936 if (isSelfPaintingLayer()) { 1936 if (isSelfPaintingLayer()) {
1937 HitTestResult tempResult(result.hitTestLocation()); 1937 HitTestResult tempResult(result.hitTestLocation());
1938 bool insideFragmentBackgroundRect = false; 1938 bool insideFragmentBackgroundRect = false;
1939 if (hitTestContentsForFragments(layerFragments, request, tempResult, hit TestLocation, HitTestSelf, insideFragmentBackgroundRect) 1939 if (hitTestContentsForFragments(layerFragments, request, tempResult, hit TestLocation, HitTestSelf, insideFragmentBackgroundRect)
1940 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) { 1940 && isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTra nsformState.get())) {
1941 if (result.isRectBasedTest()) 1941 if (result.isRectBasedTest())
1942 result.append(tempResult); 1942 result.append(tempResult, request);
1943 else 1943 else
1944 result = tempResult; 1944 result = tempResult;
1945 return this; 1945 return this;
1946 } 1946 }
1947 if (insideFragmentBackgroundRect && result.isRectBasedTest()) 1947 if (insideFragmentBackgroundRect && request.listBased())
1948 result.append(tempResult); 1948 result.append(tempResult, request);
1949 } 1949 }
1950 1950
1951 return 0; 1951 return 0;
1952 } 1952 }
1953 1953
1954 bool Layer::hitTestContentsForFragments(const LayerFragments& layerFragments, co nst HitTestRequest& request, HitTestResult& result, 1954 bool Layer::hitTestContentsForFragments(const LayerFragments& layerFragments, co nst HitTestRequest& request, HitTestResult& result,
1955 const HitTestLocation& hitTestLocation, HitTestFilter hitTestFilter, bool& i nsideClipRect) const 1955 const HitTestLocation& hitTestLocation, HitTestFilter hitTestFilter, bool& i nsideClipRect) const
1956 { 1956 {
1957 if (layerFragments.isEmpty()) 1957 if (layerFragments.isEmpty())
1958 return false; 1958 return false;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 return hitTestLayer(this, containerLayer, request, result, localHitTestRect, newHitTestLocation, true, newTransformState.get(), zOffset); 2037 return hitTestLayer(this, containerLayer, request, result, localHitTestRect, newHitTestLocation, true, newTransformState.get(), zOffset);
2038 } 2038 }
2039 2039
2040 bool Layer::hitTestContents(const HitTestRequest& request, HitTestResult& result , const LayoutRect& layerBounds, const HitTestLocation& hitTestLocation, HitTest Filter hitTestFilter) const 2040 bool Layer::hitTestContents(const HitTestRequest& request, HitTestResult& result , const LayoutRect& layerBounds, const HitTestLocation& hitTestLocation, HitTest Filter hitTestFilter) const
2041 { 2041 {
2042 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()); 2042 ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
2043 2043
2044 if (!renderer()->hitTest(request, result, hitTestLocation, toLayoutPoint(lay erBounds.location() - renderBoxLocation()), hitTestFilter)) { 2044 if (!renderer()->hitTest(request, result, hitTestLocation, toLayoutPoint(lay erBounds.location() - renderBoxLocation()), hitTestFilter)) {
2045 // It's wrong to set innerNode, but then claim that you didn't hit anyth ing, unless it is 2045 // It's wrong to set innerNode, but then claim that you didn't hit anyth ing, unless it is
2046 // a rect-based test. 2046 // a rect-based test.
2047 ASSERT(!result.innerNode() || (result.isRectBasedTest() && result.rectBa sedTestResult().size())); 2047 ASSERT(!result.innerNode() || (request.listBased() && result.listBasedTe stResult().size()));
2048 return false; 2048 return false;
2049 } 2049 }
2050 2050
2051 // For positioned generated content, we might still not have a 2051 // For positioned generated content, we might still not have a
2052 // node by the time we get to the layer level, since none of 2052 // node by the time we get to the layer level, since none of
2053 // the content in the layer has an element. So just walk up 2053 // the content in the layer has an element. So just walk up
2054 // the tree. 2054 // the tree.
2055 if (!result.innerNode() || !result.innerNonSharedNode()) { 2055 if (!result.innerNode() || !result.innerNonSharedNode()) {
2056 Node* e = enclosingElement(); 2056 Node* e = enclosingElement();
2057 if (!result.innerNode()) 2057 if (!result.innerNode())
(...skipping 20 matching lines...) Expand all
2078 LayerStackingNodeReverseIterator iterator(*m_stackingNode, childrentoVisit); 2078 LayerStackingNodeReverseIterator iterator(*m_stackingNode, childrentoVisit);
2079 while (LayerStackingNode* child = iterator.next()) { 2079 while (LayerStackingNode* child = iterator.next()) {
2080 Layer* childLayer = child->layer(); 2080 Layer* childLayer = child->layer();
2081 Layer* hitLayer = 0; 2081 Layer* hitLayer = 0;
2082 HitTestResult tempResult(result.hitTestLocation()); 2082 HitTestResult tempResult(result.hitTestLocation());
2083 if (childLayer->isPaginated()) 2083 if (childLayer->isPaginated())
2084 hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, request , tempResult, hitTestRect, hitTestLocation, transformState, zOffsetForDescendant s); 2084 hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, request , tempResult, hitTestRect, hitTestLocation, transformState, zOffsetForDescendant s);
2085 else 2085 else
2086 hitLayer = childLayer->hitTestLayer(rootLayer, this, request, tempRe sult, hitTestRect, hitTestLocation, false, transformState, zOffsetForDescendants ); 2086 hitLayer = childLayer->hitTestLayer(rootLayer, this, request, tempRe sult, hitTestRect, hitTestLocation, false, transformState, zOffsetForDescendants );
2087 2087
2088 // If it a rect-based test, we can safely append the temporary result si nce it might had hit 2088 // If it is a list-based test, we can safely append the temporary result since it might had hit
2089 // nodes but not necesserily had hitLayer set. 2089 // nodes but not necesserily had hitLayer set.
2090 if (result.isRectBasedTest()) 2090 ASSERT(!result.isRectBasedTest() || request.listBased());
2091 result.append(tempResult); 2091 if (request.listBased())
2092 result.append(tempResult, request);
2092 2093
2093 if (isHitCandidate(hitLayer, depthSortDescendants, zOffset, unflattenedT ransformState)) { 2094 if (isHitCandidate(hitLayer, depthSortDescendants, zOffset, unflattenedT ransformState)) {
2094 resultLayer = hitLayer; 2095 resultLayer = hitLayer;
2095 if (!result.isRectBasedTest()) 2096 if (!request.listBased())
2096 result = tempResult; 2097 result = tempResult;
2097 if (!depthSortDescendants) 2098 if (!depthSortDescendants)
2098 break; 2099 break;
2099 } 2100 }
2100 } 2101 }
2101 2102
2102 return resultLayer; 2103 return resultLayer;
2103 } 2104 }
2104 2105
2105 Layer* Layer::hitTestPaginatedChildLayer(Layer* childLayer, Layer* rootLayer, co nst HitTestRequest& request, HitTestResult& result, 2106 Layer* Layer::hitTestPaginatedChildLayer(Layer* childLayer, Layer* rootLayer, co nst HitTestRequest& request, HitTestResult& result,
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2950 } 2951 }
2951 } 2952 }
2952 2953
2953 void showLayerTree(const blink::LayoutObject* renderer) 2954 void showLayerTree(const blink::LayoutObject* renderer)
2954 { 2955 {
2955 if (!renderer) 2956 if (!renderer)
2956 return; 2957 return;
2957 showLayerTree(renderer->enclosingLayer()); 2958 showLayerTree(renderer->enclosingLayer());
2958 } 2959 }
2959 #endif 2960 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/HitTestResult.cpp ('k') | Source/core/layout/LayoutImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698