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: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 1907213002: Refactor OverlayScrollbarSizeRelevancy into OverlayScrollbarClipBehavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 ASSERT(!m_scrollableArea); 1478 ASSERT(!m_scrollableArea);
1479 if (requiresScrollableArea()) 1479 if (requiresScrollableArea())
1480 m_scrollableArea = PaintLayerScrollableArea::create(*this); 1480 m_scrollableArea = PaintLayerScrollableArea::create(*this);
1481 } 1481 }
1482 1482
1483 bool PaintLayer::hasOverflowControls() const 1483 bool PaintLayer::hasOverflowControls() const
1484 { 1484 {
1485 return m_scrollableArea && (m_scrollableArea->hasScrollbar() || m_scrollable Area->scrollCorner() || layoutObject()->style()->resize() != RESIZE_NONE); 1485 return m_scrollableArea && (m_scrollableArea->hasScrollbar() || m_scrollable Area->scrollCorner() || layoutObject()->style()->resize() != RESIZE_NONE);
1486 } 1486 }
1487 1487
1488 void PaintLayer::appendSingleFragmentIgnoringPagination(PaintLayerFragments& fra gments, const PaintLayer* rootLayer, const LayoutRect& dirtyRect, ClipRectsCache Slot clipRectsCacheSlot, OverlayScrollbarSizeRelevancy inOverlayScrollbarSizeRel evancy, ShouldRespectOverflowClipType respectOverflowClip, const LayoutPoint* of fsetFromRoot, const LayoutSize& subPixelAccumulation) 1488 void PaintLayer::appendSingleFragmentIgnoringPagination(PaintLayerFragments& fra gments, const PaintLayer* rootLayer, const LayoutRect& dirtyRect, ClipRectsCache Slot clipRectsCacheSlot, OverlayScrollbarClipBehavior overlayScrollbarClipBehavi or, ShouldRespectOverflowClipType respectOverflowClip, const LayoutPoint* offset FromRoot, const LayoutSize& subPixelAccumulation)
1489 { 1489 {
1490 PaintLayerFragment fragment; 1490 PaintLayerFragment fragment;
1491 ClipRectsContext clipRectsContext(rootLayer, clipRectsCacheSlot, inOverlaySc rollbarSizeRelevancy, subPixelAccumulation); 1491 ClipRectsContext clipRectsContext(rootLayer, clipRectsCacheSlot, overlayScro llbarClipBehavior, subPixelAccumulation);
1492 if (respectOverflowClip == IgnoreOverflowClip) 1492 if (respectOverflowClip == IgnoreOverflowClip)
1493 clipRectsContext.setIgnoreOverflowClip(); 1493 clipRectsContext.setIgnoreOverflowClip();
1494 clipper().calculateRects(clipRectsContext, dirtyRect, fragment.layerBounds, fragment.backgroundRect, fragment.foregroundRect, offsetFromRoot); 1494 clipper().calculateRects(clipRectsContext, dirtyRect, fragment.layerBounds, fragment.backgroundRect, fragment.foregroundRect, offsetFromRoot);
1495 fragments.append(fragment); 1495 fragments.append(fragment);
1496 } 1496 }
1497 1497
1498 void PaintLayer::collectFragments(PaintLayerFragments& fragments, const PaintLay er* rootLayer, const LayoutRect& dirtyRect, 1498 void PaintLayer::collectFragments(PaintLayerFragments& fragments, const PaintLay er* rootLayer, const LayoutRect& dirtyRect,
1499 ClipRectsCacheSlot clipRectsCacheSlot, OverlayScrollbarSizeRelevancy inOverl ayScrollbarSizeRelevancy, ShouldRespectOverflowClipType respectOverflowClip, con st LayoutPoint* offsetFromRoot, 1499 ClipRectsCacheSlot clipRectsCacheSlot, OverlayScrollbarClipBehavior overlayS crollbarClipBehavior, ShouldRespectOverflowClipType respectOverflowClip, const L ayoutPoint* offsetFromRoot,
1500 const LayoutSize& subPixelAccumulation, const LayoutRect* layerBoundingBox) 1500 const LayoutSize& subPixelAccumulation, const LayoutRect* layerBoundingBox)
1501 { 1501 {
1502 if (!enclosingPaginationLayer()) { 1502 if (!enclosingPaginationLayer()) {
1503 // For unpaginated layers, there is only one fragment. 1503 // For unpaginated layers, there is only one fragment.
1504 appendSingleFragmentIgnoringPagination(fragments, rootLayer, dirtyRect, clipRectsCacheSlot, inOverlayScrollbarSizeRelevancy, respectOverflowClip, offset FromRoot, subPixelAccumulation); 1504 appendSingleFragmentIgnoringPagination(fragments, rootLayer, dirtyRect, clipRectsCacheSlot, overlayScrollbarClipBehavior, respectOverflowClip, offsetFro mRoot, subPixelAccumulation);
1505 return; 1505 return;
1506 } 1506 }
1507 1507
1508 // Compute our offset within the enclosing pagination layer. 1508 // Compute our offset within the enclosing pagination layer.
1509 LayoutPoint offsetWithinPaginatedLayer; 1509 LayoutPoint offsetWithinPaginatedLayer;
1510 convertToLayerCoords(enclosingPaginationLayer(), offsetWithinPaginatedLayer) ; 1510 convertToLayerCoords(enclosingPaginationLayer(), offsetWithinPaginatedLayer) ;
1511 1511
1512 // Calculate clip rects relative to the enclosingPaginationLayer. The purpos e of this call is to determine our bounds clipped to intermediate 1512 // Calculate clip rects relative to the enclosingPaginationLayer. The purpos e of this call is to determine our bounds clipped to intermediate
1513 // layers between us and the pagination context. It's important to minimize the number of fragments we need to create and this helps with that. 1513 // layers between us and the pagination context. It's important to minimize the number of fragments we need to create and this helps with that.
1514 ClipRectsContext paginationClipRectsContext(enclosingPaginationLayer(), clip RectsCacheSlot, inOverlayScrollbarSizeRelevancy); 1514 ClipRectsContext paginationClipRectsContext(enclosingPaginationLayer(), clip RectsCacheSlot, overlayScrollbarClipBehavior);
1515 if (respectOverflowClip == IgnoreOverflowClip) 1515 if (respectOverflowClip == IgnoreOverflowClip)
1516 paginationClipRectsContext.setIgnoreOverflowClip(); 1516 paginationClipRectsContext.setIgnoreOverflowClip();
1517 LayoutRect layerBoundsInFlowThread; 1517 LayoutRect layerBoundsInFlowThread;
1518 ClipRect backgroundRectInFlowThread; 1518 ClipRect backgroundRectInFlowThread;
1519 ClipRect foregroundRectInFlowThread; 1519 ClipRect foregroundRectInFlowThread;
1520 clipper().calculateRects(paginationClipRectsContext, LayoutRect(LayoutRect:: infiniteIntRect()), layerBoundsInFlowThread, 1520 clipper().calculateRects(paginationClipRectsContext, LayoutRect(LayoutRect:: infiniteIntRect()), layerBoundsInFlowThread,
1521 backgroundRectInFlowThread, foregroundRectInFlowThread, &offsetWithinPag inatedLayer); 1521 backgroundRectInFlowThread, foregroundRectInFlowThread, &offsetWithinPag inatedLayer);
1522 1522
1523 // Take our bounding box within the flow thread and clip it. 1523 // Take our bounding box within the flow thread and clip it.
1524 LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingB ox : physicalBoundingBox(offsetWithinPaginatedLayer); 1524 LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingB ox : physicalBoundingBox(offsetWithinPaginatedLayer);
(...skipping 17 matching lines...) Expand all
1542 // that intersect the actual dirtyRect as well as the pages/columns that int ersect our layer's bounding box. 1542 // that intersect the actual dirtyRect as well as the pages/columns that int ersect our layer's bounding box.
1543 enclosingFlowThread->collectLayerFragments(fragments, layerBoundingBoxInFlow Thread, dirtyRectInFlowThread); 1543 enclosingFlowThread->collectLayerFragments(fragments, layerBoundingBoxInFlow Thread, dirtyRectInFlowThread);
1544 1544
1545 if (fragments.isEmpty()) 1545 if (fragments.isEmpty())
1546 return; 1546 return;
1547 1547
1548 // Get the parent clip rects of the pagination layer, since we need to inter sect with that when painting column contents. 1548 // Get the parent clip rects of the pagination layer, since we need to inter sect with that when painting column contents.
1549 ClipRect ancestorClipRect = dirtyRect; 1549 ClipRect ancestorClipRect = dirtyRect;
1550 if (const PaintLayer* paginationParentLayer = enclosingPaginationLayer()->pa rent()) { 1550 if (const PaintLayer* paginationParentLayer = enclosingPaginationLayer()->pa rent()) {
1551 const PaintLayer* ancestorLayer = rootLayerIsInsidePaginationLayer ? pag inationParentLayer : rootLayer; 1551 const PaintLayer* ancestorLayer = rootLayerIsInsidePaginationLayer ? pag inationParentLayer : rootLayer;
1552 ClipRectsContext clipRectsContext(ancestorLayer, clipRectsCacheSlot, inO verlayScrollbarSizeRelevancy); 1552 ClipRectsContext clipRectsContext(ancestorLayer, clipRectsCacheSlot, ove rlayScrollbarClipBehavior);
1553 if (respectOverflowClip == IgnoreOverflowClip) 1553 if (respectOverflowClip == IgnoreOverflowClip)
1554 clipRectsContext.setIgnoreOverflowClip(); 1554 clipRectsContext.setIgnoreOverflowClip();
1555 ancestorClipRect = enclosingPaginationLayer()->clipper().backgroundClipR ect(clipRectsContext); 1555 ancestorClipRect = enclosingPaginationLayer()->clipper().backgroundClipR ect(clipRectsContext);
1556 if (rootLayerIsInsidePaginationLayer) 1556 if (rootLayerIsInsidePaginationLayer)
1557 ancestorClipRect.moveBy(-rootLayer->visualOffsetFromAncestor(ancesto rLayer)); 1557 ancestorClipRect.moveBy(-rootLayer->visualOffsetFromAncestor(ancesto rLayer));
1558 ancestorClipRect.intersect(dirtyRect); 1558 ancestorClipRect.intersect(dirtyRect);
1559 } 1559 }
1560 1560
1561 const LayoutSize subPixelAccumulationIfNeeded = offsetFromRoot ? subPixelAcc umulation : LayoutSize(); 1561 const LayoutSize subPixelAccumulationIfNeeded = offsetFromRoot ? subPixelAcc umulation : LayoutSize();
1562 for (size_t i = 0; i < fragments.size(); ++i) { 1562 for (size_t i = 0; i < fragments.size(); ++i) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 1751
1752 ClipRectsCacheSlot clipRectsCacheSlot = result.hitTestRequest().ignoreClippi ng() ? RootRelativeClipRectsIgnoringViewportClip : RootRelativeClipRects; 1752 ClipRectsCacheSlot clipRectsCacheSlot = result.hitTestRequest().ignoreClippi ng() ? RootRelativeClipRectsIgnoringViewportClip : RootRelativeClipRects;
1753 1753
1754 // Apply a transform if we have one. 1754 // Apply a transform if we have one.
1755 if (transform() && !appliedTransform) { 1755 if (transform() && !appliedTransform) {
1756 if (enclosingPaginationLayer()) 1756 if (enclosingPaginationLayer())
1757 return hitTestTransformedLayerInFragments(rootLayer, containerLayer, result, hitTestRect, hitTestLocation, transformState, zOffset, clipRectsCacheSl ot); 1757 return hitTestTransformedLayerInFragments(rootLayer, containerLayer, result, hitTestRect, hitTestLocation, transformState, zOffset, clipRectsCacheSl ot);
1758 1758
1759 // Make sure the parent's clip rects have been calculated. 1759 // Make sure the parent's clip rects have been calculated.
1760 if (parent()) { 1760 if (parent()) {
1761 ClipRect clipRect = clipper().backgroundClipRect(ClipRectsContext(ro otLayer, clipRectsCacheSlot, IncludeOverlayScrollbarSize)); 1761 ClipRect clipRect = clipper().backgroundClipRect(ClipRectsContext(ro otLayer, clipRectsCacheSlot, IncludeOverlayScrollbarSizeForHitTesting));
1762 // Go ahead and test the enclosing clip now. 1762 // Go ahead and test the enclosing clip now.
1763 if (!clipRect.intersects(hitTestLocation)) 1763 if (!clipRect.intersects(hitTestLocation))
1764 return nullptr; 1764 return nullptr;
1765 } 1765 }
1766 1766
1767 return hitTestLayerByApplyingTransform(rootLayer, containerLayer, result , hitTestRect, hitTestLocation, transformState, zOffset); 1767 return hitTestLayerByApplyingTransform(rootLayer, containerLayer, result , hitTestRect, hitTestLocation, transformState, zOffset);
1768 } 1768 }
1769 1769
1770 if (hitTestClippedOutByClipPath(rootLayer, hitTestLocation)) 1770 if (hitTestClippedOutByClipPath(rootLayer, hitTestLocation))
1771 return nullptr; 1771 return nullptr;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 localTransformState.get(), zOffsetForDescendantsPtr, zOffset, unflattene dTransformState.get(), depthSortDescendants); 1836 localTransformState.get(), zOffsetForDescendantsPtr, zOffset, unflattene dTransformState.get(), depthSortDescendants);
1837 if (hitLayer) { 1837 if (hitLayer) {
1838 if (!depthSortDescendants) 1838 if (!depthSortDescendants)
1839 return hitLayer; 1839 return hitLayer;
1840 candidateLayer = hitLayer; 1840 candidateLayer = hitLayer;
1841 } 1841 }
1842 1842
1843 // Collect the fragments. This will compute the clip rectangles for each lay er fragment. 1843 // Collect the fragments. This will compute the clip rectangles for each lay er fragment.
1844 PaintLayerFragments layerFragments; 1844 PaintLayerFragments layerFragments;
1845 if (appliedTransform) 1845 if (appliedTransform)
1846 appendSingleFragmentIgnoringPagination(layerFragments, rootLayer, hitTes tRect, clipRectsCacheSlot, IncludeOverlayScrollbarSize); 1846 appendSingleFragmentIgnoringPagination(layerFragments, rootLayer, hitTes tRect, clipRectsCacheSlot, IncludeOverlayScrollbarSizeForHitTesting);
1847 else 1847 else
1848 collectFragments(layerFragments, rootLayer, hitTestRect, clipRectsCacheS lot, IncludeOverlayScrollbarSize); 1848 collectFragments(layerFragments, rootLayer, hitTestRect, clipRectsCacheS lot, IncludeOverlayScrollbarSizeForHitTesting);
1849 1849
1850 if (m_scrollableArea && m_scrollableArea->hitTestResizerInFragments(layerFra gments, hitTestLocation)) { 1850 if (m_scrollableArea && m_scrollableArea->hitTestResizerInFragments(layerFra gments, hitTestLocation)) {
1851 layoutObject()->updateHitTestResult(result, hitTestLocation.point()); 1851 layoutObject()->updateHitTestResult(result, hitTestLocation.point());
1852 return this; 1852 return this;
1853 } 1853 }
1854 1854
1855 // Next we want to see if the mouse pos is inside the child LayoutObjects of the layer. Check 1855 // Next we want to see if the mouse pos is inside the child LayoutObjects of the layer. Check
1856 // every fragment in reverse order. 1856 // every fragment in reverse order.
1857 if (isSelfPaintingLayer()) { 1857 if (isSelfPaintingLayer()) {
1858 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost. 1858 // Hit test with a temporary HitTestResult, because we only want to comm it to 'result' if we know we're frontmost.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 } 1924 }
1925 1925
1926 PaintLayer* PaintLayer::hitTestTransformedLayerInFragments(PaintLayer* rootLayer , PaintLayer* containerLayer, HitTestResult& result, 1926 PaintLayer* PaintLayer::hitTestTransformedLayerInFragments(PaintLayer* rootLayer , PaintLayer* containerLayer, HitTestResult& result,
1927 const LayoutRect& hitTestRect, const HitTestLocation& hitTestLocation, const HitTestingTransformState* transformState, double* zOffset, ClipRectsCacheSlot c lipRectsCacheSlot) 1927 const LayoutRect& hitTestRect, const HitTestLocation& hitTestLocation, const HitTestingTransformState* transformState, double* zOffset, ClipRectsCacheSlot c lipRectsCacheSlot)
1928 { 1928 {
1929 PaintLayerFragments enclosingPaginationFragments; 1929 PaintLayerFragments enclosingPaginationFragments;
1930 LayoutPoint offsetOfPaginationLayerFromRoot; 1930 LayoutPoint offsetOfPaginationLayerFromRoot;
1931 // FIXME: We're missing a sub-pixel offset here crbug.com/348728 1931 // FIXME: We're missing a sub-pixel offset here crbug.com/348728
1932 LayoutRect transformedExtent = transparencyClipBox(this, enclosingPagination Layer(), HitTestingTransparencyClipBox, PaintLayer::RootOfTransparencyClipBox, L ayoutSize()); 1932 LayoutRect transformedExtent = transparencyClipBox(this, enclosingPagination Layer(), HitTestingTransparencyClipBox, PaintLayer::RootOfTransparencyClipBox, L ayoutSize());
1933 enclosingPaginationLayer()->collectFragments(enclosingPaginationFragments, r ootLayer, hitTestRect, 1933 enclosingPaginationLayer()->collectFragments(enclosingPaginationFragments, r ootLayer, hitTestRect,
1934 clipRectsCacheSlot, IncludeOverlayScrollbarSize, RespectOverflowClip, &o ffsetOfPaginationLayerFromRoot, LayoutSize(), &transformedExtent); 1934 clipRectsCacheSlot, IncludeOverlayScrollbarSizeForHitTesting, RespectOve rflowClip, &offsetOfPaginationLayerFromRoot, LayoutSize(), &transformedExtent);
1935 1935
1936 for (int i = enclosingPaginationFragments.size() - 1; i >= 0; --i) { 1936 for (int i = enclosingPaginationFragments.size() - 1; i >= 0; --i) {
1937 const PaintLayerFragment& fragment = enclosingPaginationFragments.at(i); 1937 const PaintLayerFragment& fragment = enclosingPaginationFragments.at(i);
1938 1938
1939 // Apply the page/column clip for this fragment, as well as any clips es tablished by layers in between us and 1939 // Apply the page/column clip for this fragment, as well as any clips es tablished by layers in between us and
1940 // the enclosing pagination layer. 1940 // the enclosing pagination layer.
1941 LayoutRect clipRect = fragment.backgroundRect.rect(); 1941 LayoutRect clipRect = fragment.backgroundRect.rect();
1942 1942
1943 // Now compute the clips within a given fragment 1943 // Now compute the clips within a given fragment
1944 if (parent() != enclosingPaginationLayer()) { 1944 if (parent() != enclosingPaginationLayer()) {
1945 enclosingPaginationLayer()->convertToLayerCoords(rootLayer, offsetOf PaginationLayerFromRoot); 1945 enclosingPaginationLayer()->convertToLayerCoords(rootLayer, offsetOf PaginationLayerFromRoot);
1946 LayoutRect parentClipRect = clipper().backgroundClipRect(ClipRectsCo ntext(enclosingPaginationLayer(), clipRectsCacheSlot, IncludeOverlayScrollbarSiz e)).rect(); 1946 LayoutRect parentClipRect = clipper().backgroundClipRect(ClipRectsCo ntext(enclosingPaginationLayer(), clipRectsCacheSlot, IncludeOverlayScrollbarSiz eForHitTesting)).rect();
1947 parentClipRect.moveBy(fragment.paginationOffset + offsetOfPagination LayerFromRoot); 1947 parentClipRect.moveBy(fragment.paginationOffset + offsetOfPagination LayerFromRoot);
1948 clipRect.intersect(parentClipRect); 1948 clipRect.intersect(parentClipRect);
1949 } 1949 }
1950 1950
1951 if (!hitTestLocation.intersects(clipRect)) 1951 if (!hitTestLocation.intersects(clipRect))
1952 continue; 1952 continue;
1953 1953
1954 PaintLayer* hitLayer = hitTestLayerByApplyingTransform(rootLayer, contai nerLayer, result, hitTestRect, hitTestLocation, 1954 PaintLayer* hitLayer = hitTestLayerByApplyingTransform(rootLayer, contai nerLayer, result, hitTestRect, hitTestLocation,
1955 transformState, zOffset, fragment.paginationOffset); 1955 transformState, zOffset, fragment.paginationOffset);
1956 if (hitLayer) 1956 if (hitLayer)
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
2941 2941
2942 void showLayerTree(const blink::LayoutObject* layoutObject) 2942 void showLayerTree(const blink::LayoutObject* layoutObject)
2943 { 2943 {
2944 if (!layoutObject) { 2944 if (!layoutObject) {
2945 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2945 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2946 return; 2946 return;
2947 } 2947 }
2948 showLayerTree(layoutObject->enclosingLayer()); 2948 showLayerTree(layoutObject->enclosingLayer());
2949 } 2949 }
2950 #endif 2950 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698