| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 containingBlock->isLayoutView() | 777 containingBlock->isLayoutView() |
| 778 ? containingBlock->logicalWidth() | 778 ? containingBlock->logicalWidth() |
| 779 : containingBlock->containingBlockLogicalWidthForContent(); | 779 : containingBlock->containingBlockLogicalWidthForContent(); |
| 780 // Sticky positioned element ignore any override logical width on the | 780 // Sticky positioned element ignore any override logical width on the |
| 781 // containing block, as they don't call containingBlockLogicalWidthForContent. | 781 // containing block, as they don't call containingBlockLogicalWidthForContent. |
| 782 // It's unclear whether this is totally fine. | 782 // It's unclear whether this is totally fine. |
| 783 // Compute the container-relative area within which the sticky element is | 783 // Compute the container-relative area within which the sticky element is |
| 784 // allowed to move. | 784 // allowed to move. |
| 785 LayoutUnit maxWidth = containingBlock->availableLogicalWidth(); | 785 LayoutUnit maxWidth = containingBlock->availableLogicalWidth(); |
| 786 | 786 |
| 787 // Map the containing block to the scroll ancestor without transforms. | 787 // Map the containing block to the inner corner of the scroll ancestor without |
| 788 // transforms. |
| 788 FloatRect scrollContainerRelativePaddingBoxRect( | 789 FloatRect scrollContainerRelativePaddingBoxRect( |
| 789 containingBlock->layoutOverflowRect()); | 790 containingBlock->layoutOverflowRect()); |
| 791 FloatSize scrollContainerBorderOffset; |
| 792 if (scrollAncestor) { |
| 793 scrollContainerBorderOffset = |
| 794 FloatSize(scrollAncestor->borderLeft(), scrollAncestor->borderTop()); |
| 795 } |
| 790 if (containingBlock != scrollAncestor) { | 796 if (containingBlock != scrollAncestor) { |
| 791 FloatQuad localQuad(FloatRect(containingBlock->paddingBoxRect())); | 797 FloatQuad localQuad(FloatRect(containingBlock->paddingBoxRect())); |
| 792 TransformState transformState(TransformState::ApplyTransformDirection, | 798 TransformState transformState(TransformState::ApplyTransformDirection, |
| 793 localQuad.boundingBox().center(), localQuad); | 799 localQuad.boundingBox().center(), localQuad); |
| 794 containingBlock->mapLocalToAncestor(scrollAncestor, transformState, | 800 containingBlock->mapLocalToAncestor(scrollAncestor, transformState, |
| 795 ApplyContainerFlip); | 801 ApplyContainerFlip); |
| 796 transformState.flatten(); | 802 transformState.flatten(); |
| 797 scrollContainerRelativePaddingBoxRect = | 803 scrollContainerRelativePaddingBoxRect = |
| 798 transformState.lastPlanarQuad().boundingBox(); | 804 transformState.lastPlanarQuad().boundingBox(); |
| 799 | 805 |
| 800 // The sticky position constraint rects should be independent of the current | 806 // The sticky position constraint rects should be independent of the current |
| 801 // scroll position, so after mapping we add in the scroll position to get | 807 // scroll position, so after mapping we add in the scroll position to get |
| 802 // the container's position within the ancestor scroller's unscrolled layout | 808 // the container's position within the ancestor scroller's unscrolled layout |
| 803 // overflow. | 809 // overflow. |
| 804 ScrollOffset scrollOffset( | 810 ScrollOffset scrollOffset( |
| 805 scrollAncestor | 811 scrollAncestor |
| 806 ? toFloatSize(scrollAncestor->getScrollableArea()->scrollPosition()) | 812 ? toFloatSize(scrollAncestor->getScrollableArea()->scrollPosition()) |
| 807 : FloatSize()); | 813 : FloatSize()); |
| 808 scrollContainerRelativePaddingBoxRect.move(scrollOffset); | 814 scrollContainerRelativePaddingBoxRect.move(scrollOffset); |
| 809 } | 815 } |
| 816 // Remove top-left border offset from overflow scroller. |
| 817 scrollContainerRelativePaddingBoxRect.move(-scrollContainerBorderOffset); |
| 810 | 818 |
| 811 LayoutRect scrollContainerRelativeContainingBlockRect( | 819 LayoutRect scrollContainerRelativeContainingBlockRect( |
| 812 scrollContainerRelativePaddingBoxRect); | 820 scrollContainerRelativePaddingBoxRect); |
| 813 // This is removing the padding of the containing block's overflow rect to get | 821 // This is removing the padding of the containing block's overflow rect to get |
| 814 // the flow box rectangle and removing the margin of the sticky element to | 822 // the flow box rectangle and removing the margin of the sticky element to |
| 815 // ensure that space between the sticky element and its containing flow box. | 823 // ensure that space between the sticky element and its containing flow box. |
| 816 // It is an open issue whether the margin should collapse. | 824 // It is an open issue whether the margin should collapse. |
| 817 // See https://www.w3.org/TR/css-position-3/#sticky-pos | 825 // See https://www.w3.org/TR/css-position-3/#sticky-pos |
| 818 scrollContainerRelativeContainingBlockRect.contractEdges( | 826 scrollContainerRelativeContainingBlockRect.contractEdges( |
| 819 minimumValueForLength(containingBlock->style()->paddingTop(), | 827 minimumValueForLength(containingBlock->style()->paddingTop(), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 835 FloatRect stickyBoxRect = | 843 FloatRect stickyBoxRect = |
| 836 isLayoutInline() ? FloatRect(toLayoutInline(this)->linesBoundingBox()) | 844 isLayoutInline() ? FloatRect(toLayoutInline(this)->linesBoundingBox()) |
| 837 : FloatRect(toLayoutBox(this)->frameRect()); | 845 : FloatRect(toLayoutBox(this)->frameRect()); |
| 838 FloatRect flippedStickyBoxRect = stickyBoxRect; | 846 FloatRect flippedStickyBoxRect = stickyBoxRect; |
| 839 containingBlock->flipForWritingMode(flippedStickyBoxRect); | 847 containingBlock->flipForWritingMode(flippedStickyBoxRect); |
| 840 FloatPoint stickyLocation = | 848 FloatPoint stickyLocation = |
| 841 flippedStickyBoxRect.location() + skippedContainersOffset; | 849 flippedStickyBoxRect.location() + skippedContainersOffset; |
| 842 | 850 |
| 843 // The scrollContainerRelativePaddingBoxRect's position is the padding box so | 851 // The scrollContainerRelativePaddingBoxRect's position is the padding box so |
| 844 // we need to remove the border when finding the position of the sticky box | 852 // we need to remove the border when finding the position of the sticky box |
| 845 // within the scroll ancestor if the container is not our scroll ancestor. | 853 // within the scroll ancestor if the container is not our scroll ancestor. If |
| 846 if (containingBlock != scrollAncestor) { | 854 // the container is our scroll ancestor, we also need to remove the border |
| 847 FloatSize containerBorderOffset(containingBlock->borderLeft(), | 855 // box because we want the position from within the scroller border. |
| 848 containingBlock->borderTop()); | 856 FloatSize containerBorderOffset(containingBlock->borderLeft(), |
| 849 stickyLocation -= containerBorderOffset; | 857 containingBlock->borderTop()); |
| 850 } | 858 stickyLocation -= containerBorderOffset; |
| 851 constraints.setScrollContainerRelativeStickyBoxRect( | 859 constraints.setScrollContainerRelativeStickyBoxRect( |
| 852 FloatRect(scrollContainerRelativePaddingBoxRect.location() + | 860 FloatRect(scrollContainerRelativePaddingBoxRect.location() + |
| 853 toFloatSize(stickyLocation), | 861 toFloatSize(stickyLocation), |
| 854 flippedStickyBoxRect.size())); | 862 flippedStickyBoxRect.size())); |
| 855 | 863 |
| 856 // We skip the right or top sticky offset if there is not enough space to | 864 // We skip the right or top sticky offset if there is not enough space to |
| 857 // honor both the left/right or top/bottom offsets. | 865 // honor both the left/right or top/bottom offsets. |
| 858 LayoutUnit horizontalOffsets = | 866 LayoutUnit horizontalOffsets = |
| 859 minimumValueForLength(style()->right(), | 867 minimumValueForLength(style()->right(), |
| 860 LayoutUnit(constrainingSize.width())) + | 868 LayoutUnit(constrainingSize.width())) + |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 FloatRect LayoutBoxModelObject::computeStickyConstrainingRect() const { | 930 FloatRect LayoutBoxModelObject::computeStickyConstrainingRect() const { |
| 923 if (layer()->ancestorOverflowLayer()->isRootLayer()) | 931 if (layer()->ancestorOverflowLayer()->isRootLayer()) |
| 924 return view()->frameView()->visibleContentRect(); | 932 return view()->frameView()->visibleContentRect(); |
| 925 | 933 |
| 926 LayoutBox* enclosingClippingBox = | 934 LayoutBox* enclosingClippingBox = |
| 927 toLayoutBox(layer()->ancestorOverflowLayer()->layoutObject()); | 935 toLayoutBox(layer()->ancestorOverflowLayer()->layoutObject()); |
| 928 FloatRect constrainingRect; | 936 FloatRect constrainingRect; |
| 929 constrainingRect = | 937 constrainingRect = |
| 930 FloatRect(enclosingClippingBox->overflowClipRect(LayoutPoint(DoublePoint( | 938 FloatRect(enclosingClippingBox->overflowClipRect(LayoutPoint(DoublePoint( |
| 931 enclosingClippingBox->getScrollableArea()->scrollPosition())))); | 939 enclosingClippingBox->getScrollableArea()->scrollPosition())))); |
| 932 constrainingRect.move(enclosingClippingBox->paddingLeft(), | 940 constrainingRect.move( |
| 933 enclosingClippingBox->paddingTop()); | 941 -enclosingClippingBox->borderLeft() + enclosingClippingBox->paddingLeft(), |
| 942 -enclosingClippingBox->borderTop() + enclosingClippingBox->paddingTop()); |
| 934 constrainingRect.contract( | 943 constrainingRect.contract( |
| 935 FloatSize(enclosingClippingBox->paddingLeft() + | 944 FloatSize(enclosingClippingBox->paddingLeft() + |
| 936 enclosingClippingBox->paddingRight(), | 945 enclosingClippingBox->paddingRight(), |
| 937 enclosingClippingBox->paddingTop() + | 946 enclosingClippingBox->paddingTop() + |
| 938 enclosingClippingBox->paddingBottom())); | 947 enclosingClippingBox->paddingBottom())); |
| 939 return constrainingRect; | 948 return constrainingRect; |
| 940 } | 949 } |
| 941 | 950 |
| 942 LayoutSize LayoutBoxModelObject::stickyPositionOffset() const { | 951 LayoutSize LayoutBoxModelObject::stickyPositionOffset() const { |
| 943 const PaintLayer* ancestorOverflowLayer = layer()->ancestorOverflowLayer(); | 952 const PaintLayer* ancestorOverflowLayer = layer()->ancestorOverflowLayer(); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 if (rootElementStyle->hasBackground()) | 1328 if (rootElementStyle->hasBackground()) |
| 1320 return false; | 1329 return false; |
| 1321 | 1330 |
| 1322 if (node() != document().firstBodyElement()) | 1331 if (node() != document().firstBodyElement()) |
| 1323 return false; | 1332 return false; |
| 1324 | 1333 |
| 1325 return true; | 1334 return true; |
| 1326 } | 1335 } |
| 1327 | 1336 |
| 1328 } // namespace blink | 1337 } // namespace blink |
| OLD | NEW |