OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/paint/PaintPropertyTreeBuilder.h" | 5 #include "core/paint/PaintPropertyTreeBuilder.h" |
6 | 6 |
7 #include "core/dom/DOMNodeIds.h" | 7 #include "core/dom/DOMNodeIds.h" |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 return; | 853 return; |
854 } | 854 } |
855 } | 855 } |
856 | 856 |
857 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 857 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
858 if (auto* properties = object.getMutableForPainting().paintProperties()) | 858 if (auto* properties = object.getMutableForPainting().paintProperties()) |
859 context.forceSubtreeUpdate |= properties->clearCssClipFixedPosition(); | 859 context.forceSubtreeUpdate |= properties->clearCssClipFixedPosition(); |
860 } | 860 } |
861 } | 861 } |
862 | 862 |
863 // Override ContainingBlockContext based on the properties of a containing block | |
864 // that was previously walked in a subtree other than the current subtree being | |
865 // walked. Used for out-of-flow positioned descendants of multi-column spanner | |
866 // when the containing block is not in the normal tree walk order. | |
867 // For example: | |
868 // <div id="columns" style="columns: 2"> | |
869 // <div id="relative" style="position: relative"> | |
870 // <div id="spanner" style="column-span: all"> | |
871 // <div id="absolute" style="position: absolute"></div> | |
872 // </div> | |
873 // </div> | |
874 // <div> | |
875 // The real containing block of "absolute" is "relative" which is not in the | |
876 // tree-walk order of "columns" -> spanner placeholder -> spanner -> absolute. | |
877 // Here we rebuild a ContainingBlockContext based on the properties of | |
878 // "relative" for "absolute". | |
879 static void overrideContainingBlockContextFromRealContainingBlock( | |
880 const LayoutBlock& containingBlock, | |
881 PaintPropertyTreeBuilderContext::ContainingBlockContext& context) { | |
882 const auto* properties = | |
883 containingBlock.paintProperties()->localBorderBoxProperties(); | |
884 DCHECK(properties); | |
885 | |
886 context.transform = properties->transform(); | |
887 context.paintOffset = containingBlock.paintOffset(); | |
888 context.shouldFlattenInheritedTransform = | |
889 context.transform && context.transform->flattensInheritedTransform(); | |
890 context.renderingContextId = | |
891 context.transform ? context.transform->renderingContextId() : 0; | |
892 context.clip = properties->clip(); | |
893 context.scroll = properties->scroll(); | |
894 } | |
895 | |
896 void PaintPropertyTreeBuilder::updateContextForBoxPosition( | 863 void PaintPropertyTreeBuilder::updateContextForBoxPosition( |
897 const LayoutObject& object, | 864 const LayoutObject& object, |
898 PaintPropertyTreeBuilderContext& context) { | 865 PaintPropertyTreeBuilderContext& context) { |
899 if (!object.isBoxModelObject()) | 866 if (!object.isBoxModelObject()) |
900 return; | 867 return; |
901 | 868 |
902 const LayoutBoxModelObject& boxModelObject = toLayoutBoxModelObject(object); | 869 const LayoutBoxModelObject& boxModelObject = toLayoutBoxModelObject(object); |
903 | 870 |
904 if (boxModelObject.isFloating()) | 871 if (boxModelObject.isFloating()) |
905 context.current.paintOffset = context.paintOffsetForFloat; | 872 context.current.paintOffset = context.paintOffsetForFloat; |
906 | 873 |
| 874 // Multicolumn spanners are painted starting at the multicolumn container (but |
| 875 // still inherit properties in layout-tree order) so reset the paint offset. |
| 876 if (boxModelObject.isColumnSpanAll()) |
| 877 context.current.paintOffset = boxModelObject.container()->paintOffset(); |
| 878 |
907 switch (object.styleRef().position()) { | 879 switch (object.styleRef().position()) { |
908 case StaticPosition: | 880 case StaticPosition: |
909 break; | 881 break; |
910 case RelativePosition: | 882 case RelativePosition: |
911 context.current.paintOffset += boxModelObject.offsetForInFlowPosition(); | 883 context.current.paintOffset += boxModelObject.offsetForInFlowPosition(); |
912 break; | 884 break; |
913 case AbsolutePosition: { | 885 case AbsolutePosition: { |
914 if (context.isUnderMultiColumnSpanner) { | 886 DCHECK(context.containerForAbsolutePosition == |
915 const LayoutObject* container = boxModelObject.container(); | 887 boxModelObject.container()); |
916 if (container != context.containerForAbsolutePosition) { | 888 context.current = context.absolutePosition; |
917 // The container of the absolute-position is not in the normal tree- | |
918 // walk order. | |
919 context.containerForAbsolutePosition = | |
920 toLayoutBoxModelObject(container); | |
921 // The container is never a LayoutInline. In the example above | |
922 // overrideContainingBlockContextFromRealContainingBlock(), if we | |
923 // change the container to an inline, there will be an anonymous | |
924 // blocks created because the spanner is always a block. | |
925 overrideContainingBlockContextFromRealContainingBlock( | |
926 toLayoutBlock(*container), context.current); | |
927 } | |
928 } else { | |
929 DCHECK(context.containerForAbsolutePosition == | |
930 boxModelObject.container()); | |
931 context.current = context.absolutePosition; | |
932 } | |
933 | 889 |
934 // Absolutely positioned content in an inline should be positioned | 890 // Absolutely positioned content in an inline should be positioned |
935 // relative to the inline. | 891 // relative to the inline. |
936 const LayoutObject* container = context.containerForAbsolutePosition; | 892 const LayoutObject* container = context.containerForAbsolutePosition; |
937 if (container && container->isInFlowPositioned() && | 893 if (container && container->isInFlowPositioned() && |
938 container->isLayoutInline()) { | 894 container->isLayoutInline()) { |
939 DCHECK(object.isBox()); | 895 DCHECK(object.isBox()); |
940 context.current.paintOffset += | 896 context.current.paintOffset += |
941 toLayoutInline(container)->offsetForInFlowPositionedInline( | 897 toLayoutInline(container)->offsetForInFlowPositionedInline( |
942 toLayoutBox(object)); | 898 toLayoutBox(object)); |
943 } | 899 } |
944 break; | 900 break; |
945 } | 901 } |
946 case StickyPosition: | 902 case StickyPosition: |
947 context.current.paintOffset += boxModelObject.offsetForInFlowPosition(); | 903 context.current.paintOffset += boxModelObject.offsetForInFlowPosition(); |
948 break; | 904 break; |
949 case FixedPosition: | 905 case FixedPosition: |
950 if (context.isUnderMultiColumnSpanner) { | 906 context.current = context.fixedPosition; |
951 // The container of the fixed-position object may or may not be in the | |
952 // normal tree-walk order. | |
953 overrideContainingBlockContextFromRealContainingBlock( | |
954 toLayoutBlock(*boxModelObject.container()), context.current); | |
955 } else { | |
956 context.current = context.fixedPosition; | |
957 } | |
958 break; | 907 break; |
959 default: | 908 default: |
960 ASSERT_NOT_REACHED(); | 909 ASSERT_NOT_REACHED(); |
961 } | 910 } |
962 | 911 |
963 if (boxModelObject.isBox()) { | 912 if (boxModelObject.isBox()) { |
964 // TODO(pdr): Several calls in this function walk back up the tree to | 913 // TODO(pdr): Several calls in this function walk back up the tree to |
965 // calculate containers (e.g., physicalLocation, offsetForInFlowPosition*). | 914 // calculate containers (e.g., physicalLocation, offsetForInFlowPosition*). |
966 // The containing block and other containers can be stored on | 915 // The containing block and other containers can be stored on |
967 // PaintPropertyTreeBuilderContext instead of recomputing them. | 916 // PaintPropertyTreeBuilderContext instead of recomputing them. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 updateOverflowClip(object, context); | 966 updateOverflowClip(object, context); |
1018 updatePerspective(object, context); | 967 updatePerspective(object, context); |
1019 updateSvgLocalToBorderBoxTransform(object, context); | 968 updateSvgLocalToBorderBoxTransform(object, context); |
1020 updateScrollAndScrollTranslation(object, context); | 969 updateScrollAndScrollTranslation(object, context); |
1021 updateOutOfFlowContext(object, context); | 970 updateOutOfFlowContext(object, context); |
1022 | 971 |
1023 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 972 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
1024 } | 973 } |
1025 | 974 |
1026 } // namespace blink | 975 } // namespace blink |
OLD | NEW |