| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 | 801 |
| 802 IntPoint graphicsLayerParentLocation; | 802 IntPoint graphicsLayerParentLocation; |
| 803 computeGraphicsLayerParentLocation(compositingContainer, ancestorCompositing
Bounds, graphicsLayerParentLocation); | 803 computeGraphicsLayerParentLocation(compositingContainer, ancestorCompositing
Bounds, graphicsLayerParentLocation); |
| 804 | 804 |
| 805 // Might update graphicsLayerParentLocation. | 805 // Might update graphicsLayerParentLocation. |
| 806 updateAncestorClippingLayerGeometry(compositingContainer, snappedOffsetFromC
ompositedAncestor, graphicsLayerParentLocation); | 806 updateAncestorClippingLayerGeometry(compositingContainer, snappedOffsetFromC
ompositedAncestor, graphicsLayerParentLocation); |
| 807 | 807 |
| 808 FloatSize contentsSize(relativeCompositingBounds.size()); | 808 FloatSize contentsSize(relativeCompositingBounds.size()); |
| 809 | 809 |
| 810 updateMainGraphicsLayerGeometry(relativeCompositingBounds, localCompositingB
ounds, graphicsLayerParentLocation); | 810 updateMainGraphicsLayerGeometry(relativeCompositingBounds, localCompositingB
ounds, graphicsLayerParentLocation); |
| 811 updateOverflowControlsHostLayerGeometry(compositingStackingContext, composit
ingContainer); | 811 updateOverflowControlsHostLayerGeometry(compositingStackingContext, composit
ingContainer, graphicsLayerParentLocation); |
| 812 updateContentsOffsetInCompositingLayer(snappedOffsetFromCompositedAncestor,
graphicsLayerParentLocation); | 812 updateContentsOffsetInCompositingLayer(snappedOffsetFromCompositedAncestor,
graphicsLayerParentLocation); |
| 813 updateSquashingLayerGeometry(graphicsLayerParentLocation, compositingContain
er, m_squashedLayers, m_squashingLayer.get(), &m_squashingLayerOffsetFromTransfo
rmedAncestor, layersNeedingPaintInvalidation); | 813 updateSquashingLayerGeometry(graphicsLayerParentLocation, compositingContain
er, m_squashedLayers, m_squashingLayer.get(), &m_squashingLayerOffsetFromTransfo
rmedAncestor, layersNeedingPaintInvalidation); |
| 814 | 814 |
| 815 // If we have a layer that clips children, position it. | 815 // If we have a layer that clips children, position it. |
| 816 IntRect clippingBox; | 816 IntRect clippingBox; |
| 817 if (m_childContainmentLayer) | 817 if (m_childContainmentLayer) |
| 818 clippingBox = clipBox(toLayoutBox(layoutObject())); | 818 clippingBox = clipBox(toLayoutBox(layoutObject())); |
| 819 | 819 |
| 820 updateChildTransformLayerGeometry(); | 820 updateChildTransformLayerGeometry(); |
| 821 updateChildContainmentLayerGeometry(clippingBox, localCompositingBounds); | 821 updateChildContainmentLayerGeometry(clippingBox, localCompositingBounds); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 m_ancestorClippingLayer->setPosition(FloatPoint(parentClipRect.location() -
graphicsLayerParentLocation)); | 905 m_ancestorClippingLayer->setPosition(FloatPoint(parentClipRect.location() -
graphicsLayerParentLocation)); |
| 906 m_ancestorClippingLayer->setSize(FloatSize(parentClipRect.size())); | 906 m_ancestorClippingLayer->setSize(FloatSize(parentClipRect.size())); |
| 907 | 907 |
| 908 // backgroundRect is relative to compositingContainer, so subtract snappedOf
fsetFromCompositedAncestor.X/snappedOffsetFromCompositedAncestor.Y to get back t
o local coords. | 908 // backgroundRect is relative to compositingContainer, so subtract snappedOf
fsetFromCompositedAncestor.X/snappedOffsetFromCompositedAncestor.Y to get back t
o local coords. |
| 909 m_ancestorClippingLayer->setOffsetFromLayoutObject(parentClipRect.location()
- snappedOffsetFromCompositedAncestor); | 909 m_ancestorClippingLayer->setOffsetFromLayoutObject(parentClipRect.location()
- snappedOffsetFromCompositedAncestor); |
| 910 | 910 |
| 911 // The primary layer is then parented in, and positioned relative to this cl
ipping layer. | 911 // The primary layer is then parented in, and positioned relative to this cl
ipping layer. |
| 912 graphicsLayerParentLocation = parentClipRect.location(); | 912 graphicsLayerParentLocation = parentClipRect.location(); |
| 913 } | 913 } |
| 914 | 914 |
| 915 void CompositedLayerMapping::updateOverflowControlsHostLayerGeometry(const Paint
Layer* compositingStackingContext, const PaintLayer* compositingContainer) | 915 void CompositedLayerMapping::updateOverflowControlsHostLayerGeometry(const Paint
Layer* compositingStackingContext, const PaintLayer* compositingContainer, IntPo
int graphicsLayerParentLocation) |
| 916 { | 916 { |
| 917 if (!m_overflowControlsHostLayer) | 917 if (!m_overflowControlsHostLayer) |
| 918 return; | 918 return; |
| 919 | 919 |
| 920 // To position and clip the scrollbars correctly, m_overflowControlsHostLaye
r should match our |
| 921 // border box rect, which is at the origin of our LayoutObject. Its position
is computed in |
| 922 // various ways depending on who its parent GraphicsLayer is going to be. |
| 920 LayoutPoint hostLayerPosition; | 923 LayoutPoint hostLayerPosition; |
| 921 | 924 |
| 922 if (needsToReparentOverflowControls()) { | 925 if (needsToReparentOverflowControls()) { |
| 926 CompositedLayerMapping* stackingCLM = compositingStackingContext->compos
itedLayerMapping(); |
| 927 DCHECK(stackingCLM); |
| 928 |
| 929 // Either m_overflowControlsHostLayer or m_overflowControlsAncestorClipp
ingLayer (if it |
| 930 // exists) will be a child of the main GraphicsLayer of the compositing
stacking context. |
| 931 IntSize stackingOffsetFromLayoutObject = stackingCLM->mainGraphicsLayer(
)->offsetFromLayoutObject(); |
| 932 |
| 923 if (m_overflowControlsAncestorClippingLayer) { | 933 if (m_overflowControlsAncestorClippingLayer) { |
| 924 m_overflowControlsAncestorClippingLayer->setSize(m_ancestorClippingL
ayer->size()); | 934 m_overflowControlsAncestorClippingLayer->setSize(m_ancestorClippingL
ayer->size()); |
| 925 m_overflowControlsAncestorClippingLayer->setOffsetFromLayoutObject(m
_ancestorClippingLayer->offsetFromLayoutObject()); | 935 m_overflowControlsAncestorClippingLayer->setOffsetFromLayoutObject(m
_ancestorClippingLayer->offsetFromLayoutObject()); |
| 926 m_overflowControlsAncestorClippingLayer->setMasksToBounds(true); | 936 m_overflowControlsAncestorClippingLayer->setMasksToBounds(true); |
| 927 hostLayerPosition = toLayoutPoint(LayoutSize(-m_overflowControlsAnce
storClippingLayer->offsetFromLayoutObject())); | |
| 928 | 937 |
| 929 FloatPoint position = m_ancestorClippingLayer->position(); | 938 FloatPoint position; |
| 930 if (compositingStackingContext != compositingContainer) { | 939 if (compositingStackingContext == compositingContainer) { |
| 931 LayoutPoint offset; | 940 position = m_ancestorClippingLayer->position(); |
| 941 } else { |
| 942 // graphicsLayerParentLocation is the location of m_ancestorClip
pingLayer |
| 943 // relative to compositingContainer (including any offset from |
| 944 // compositingContainer's m_childContainmentLayer). |
| 945 LayoutPoint offset = LayoutPoint(graphicsLayerParentLocation); |
| 932 compositingContainer->convertToLayerCoords(compositingStackingCo
ntext, offset); | 946 compositingContainer->convertToLayerCoords(compositingStackingCo
ntext, offset); |
| 933 FloatSize offsetFromStackingContainer = toFloatSize(FloatPoint(o
ffset)); | 947 position = FloatPoint(offset) - FloatSize(stackingOffsetFromLayo
utObject); |
| 934 position += offsetFromStackingContainer; | |
| 935 } | 948 } |
| 936 | 949 |
| 937 m_overflowControlsAncestorClippingLayer->setPosition(position); | 950 m_overflowControlsAncestorClippingLayer->setPosition(position); |
| 951 hostLayerPosition.move(-m_ancestorClippingLayer->offsetFromLayoutObj
ect()); |
| 938 } else { | 952 } else { |
| 939 // The controls are in the same 2D space as the compositing containe
r, so we can map them into the space of the container. | 953 // The controls are in the same 2D space as the compositing containe
r, so we can map them into the space of the container. |
| 940 TransformState transformState(TransformState::ApplyTransformDirectio
n, FloatPoint()); | 954 TransformState transformState(TransformState::ApplyTransformDirectio
n, FloatPoint()); |
| 941 m_owningLayer.layoutObject()->mapLocalToAncestor(compositingStacking
Context->layoutObject(), transformState, ApplyContainerFlip); | 955 m_owningLayer.layoutObject()->mapLocalToAncestor(compositingStacking
Context->layoutObject(), transformState, ApplyContainerFlip); |
| 942 transformState.flatten(); | 956 transformState.flatten(); |
| 943 hostLayerPosition = LayoutPoint(transformState.lastPlanarPoint()); | 957 hostLayerPosition = LayoutPoint(transformState.lastPlanarPoint()); |
| 944 if (PaintLayerScrollableArea* scrollableArea = compositingStackingCo
ntext->getScrollableArea()) | 958 if (PaintLayerScrollableArea* scrollableArea = compositingStackingCo
ntext->getScrollableArea()) |
| 945 hostLayerPosition.move(LayoutSize(scrollableArea->adjustedScroll
Offset())); | 959 hostLayerPosition.move(LayoutSize(scrollableArea->adjustedScroll
Offset())); |
| 960 hostLayerPosition.move(-stackingOffsetFromLayoutObject); |
| 946 } | 961 } |
| 962 } else { |
| 963 hostLayerPosition.move(-m_graphicsLayer->offsetFromLayoutObject()); |
| 947 } | 964 } |
| 948 | 965 |
| 949 // To clip correctly, m_overflowControlsHostLayer should match the border bo
x rect, which is at | |
| 950 // the origin of the LayoutObject. The parent is m_graphicsLayer, so we must
adjust the position | |
| 951 // by the distance from m_graphicsLayer to the LayoutObject. | |
| 952 | |
| 953 IntSize offsetFromLayoutObject = m_graphicsLayer->offsetFromLayoutObject() -
roundedIntSize(m_owningLayer.subpixelAccumulation()); | |
| 954 hostLayerPosition.move(-offsetFromLayoutObject); | |
| 955 m_overflowControlsHostLayer->setPosition(FloatPoint(hostLayerPosition)); | 966 m_overflowControlsHostLayer->setPosition(FloatPoint(hostLayerPosition)); |
| 956 | 967 |
| 957 const IntRect borderBox = toLayoutBox(m_owningLayer.layoutObject())->pixelSn
appedBorderBoxRect(); | 968 const IntRect borderBox = toLayoutBox(m_owningLayer.layoutObject())->pixelSn
appedBorderBoxRect(); |
| 958 m_overflowControlsHostLayer->setSize(FloatSize(borderBox.size())); | 969 m_overflowControlsHostLayer->setSize(FloatSize(borderBox.size())); |
| 959 m_overflowControlsHostLayer->setMasksToBounds(true); | 970 m_overflowControlsHostLayer->setMasksToBounds(true); |
| 960 } | 971 } |
| 961 | 972 |
| 962 void CompositedLayerMapping::updateChildContainmentLayerGeometry(const IntRect&
clippingBox, const IntRect& localCompositingBounds) | 973 void CompositedLayerMapping::updateChildContainmentLayerGeometry(const IntRect&
clippingBox, const IntRect& localCompositingBounds) |
| 963 { | 974 { |
| 964 if (!m_childContainmentLayer) | 975 if (!m_childContainmentLayer) |
| (...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2751 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2762 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| 2752 name = "Scrolling Contents Layer"; | 2763 name = "Scrolling Contents Layer"; |
| 2753 } else { | 2764 } else { |
| 2754 ASSERT_NOT_REACHED(); | 2765 ASSERT_NOT_REACHED(); |
| 2755 } | 2766 } |
| 2756 | 2767 |
| 2757 return name; | 2768 return name; |
| 2758 } | 2769 } |
| 2759 | 2770 |
| 2760 } // namespace blink | 2771 } // namespace blink |
| OLD | NEW |