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

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

Powered by Google App Engine
This is Rietveld 408576698