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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 return; | 570 return; |
571 | 571 |
572 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since | 572 // Avoid adding an ObjectPaintProperties for non-boxes to save memory, since |
573 // we don't need them at the moment. | 573 // we don't need them at the moment. |
574 if (!object.isBox() && !object.hasLayer()) { | 574 if (!object.isBox() && !object.hasLayer()) { |
575 if (auto* properties = object.getMutableForPainting().paintProperties()) | 575 if (auto* properties = object.getMutableForPainting().paintProperties()) |
576 properties->clearLocalBorderBoxProperties(); | 576 properties->clearLocalBorderBoxProperties(); |
577 } else { | 577 } else { |
578 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 578 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
579 properties.updateLocalBorderBoxProperties( | 579 properties.updateLocalBorderBoxProperties( |
580 context.current.paintOffset, context.current.transform, | 580 context.current.transform, context.current.clip, context.currentEffect, |
581 context.current.clip, context.currentEffect, context.current.scroll); | 581 context.current.scroll); |
582 } | 582 } |
583 } | 583 } |
584 | 584 |
585 // TODO(trchen): Remove this once we bake the paint offset into frameRect. | 585 // TODO(trchen): Remove this once we bake the paint offset into frameRect. |
586 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset( | 586 void PaintPropertyTreeBuilder::updateScrollbarPaintOffset( |
587 const LayoutObject& object, | 587 const LayoutObject& object, |
588 PaintPropertyTreeBuilderContext& context) { | 588 PaintPropertyTreeBuilderContext& context) { |
589 if (!object.needsPaintPropertyUpdate() && !context.forceSubtreeUpdate) | 589 if (!object.needsPaintPropertyUpdate() && !context.forceSubtreeUpdate) |
590 return; | 590 return; |
591 | 591 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 // tree-walk order of "columns" -> spanner placeholder -> spanner -> absolute. | 873 // tree-walk order of "columns" -> spanner placeholder -> spanner -> absolute. |
874 // Here we rebuild a ContainingBlockContext based on the properties of | 874 // Here we rebuild a ContainingBlockContext based on the properties of |
875 // "relative" for "absolute". | 875 // "relative" for "absolute". |
876 static void overrideContainingBlockContextFromRealContainingBlock( | 876 static void overrideContainingBlockContextFromRealContainingBlock( |
877 const LayoutBlock& containingBlock, | 877 const LayoutBlock& containingBlock, |
878 PaintPropertyTreeBuilderContext::ContainingBlockContext& context) { | 878 PaintPropertyTreeBuilderContext::ContainingBlockContext& context) { |
879 const auto* properties = | 879 const auto* properties = |
880 containingBlock.paintProperties()->localBorderBoxProperties(); | 880 containingBlock.paintProperties()->localBorderBoxProperties(); |
881 DCHECK(properties); | 881 DCHECK(properties); |
882 | 882 |
883 context.transform = properties->propertyTreeState.transform(); | 883 context.transform = properties->transform(); |
884 context.paintOffset = properties->paintOffset; | 884 context.paintOffset = containingBlock.paintOffset(); |
885 context.shouldFlattenInheritedTransform = | 885 context.shouldFlattenInheritedTransform = |
886 context.transform && context.transform->flattensInheritedTransform(); | 886 context.transform && context.transform->flattensInheritedTransform(); |
887 context.renderingContextId = | 887 context.renderingContextId = |
888 context.transform ? context.transform->renderingContextId() : 0; | 888 context.transform ? context.transform->renderingContextId() : 0; |
889 context.clip = properties->propertyTreeState.clip(); | 889 context.clip = properties->clip(); |
890 context.scroll = properties->propertyTreeState.scroll(); | 890 context.scroll = properties->scroll(); |
891 } | 891 } |
892 | 892 |
893 void PaintPropertyTreeBuilder::updateContextForBoxPosition( | 893 void PaintPropertyTreeBuilder::updateContextForBoxPosition( |
894 const LayoutObject& object, | 894 const LayoutObject& object, |
895 PaintPropertyTreeBuilderContext& context) { | 895 PaintPropertyTreeBuilderContext& context) { |
896 if (!object.isBoxModelObject()) | 896 if (!object.isBoxModelObject()) |
897 return; | 897 return; |
898 | 898 |
899 const LayoutBoxModelObject& boxModelObject = toLayoutBoxModelObject(object); | 899 const LayoutBoxModelObject& boxModelObject = toLayoutBoxModelObject(object); |
900 switch (object.styleRef().position()) { | 900 switch (object.styleRef().position()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 if (boxModelObject.isTableCell()) { | 966 if (boxModelObject.isTableCell()) { |
967 LayoutObject* parentRow = boxModelObject.parent(); | 967 LayoutObject* parentRow = boxModelObject.parent(); |
968 DCHECK(parentRow && parentRow->isTableRow()); | 968 DCHECK(parentRow && parentRow->isTableRow()); |
969 context.current.paintOffset.moveBy( | 969 context.current.paintOffset.moveBy( |
970 -toLayoutBox(parentRow)->physicalLocation()); | 970 -toLayoutBox(parentRow)->physicalLocation()); |
971 } | 971 } |
972 } | 972 } |
973 | 973 |
974 // Many paint properties depend on paint offset so we force an update of | 974 // Many paint properties depend on paint offset so we force an update of |
975 // the entire subtree on paint offset changes. | 975 // the entire subtree on paint offset changes. |
976 if (object.previousPaintOffset() != context.current.paintOffset) | 976 if (object.paintOffset() != context.current.paintOffset) |
977 context.forceSubtreeUpdate = true; | 977 context.forceSubtreeUpdate = true; |
978 } | 978 } |
979 | 979 |
980 void PaintPropertyTreeBuilder::updatePropertiesForSelf( | 980 void PaintPropertyTreeBuilder::updatePropertiesForSelf( |
981 const LayoutObject& object, | 981 const LayoutObject& object, |
982 PaintPropertyTreeBuilderContext& context) { | 982 PaintPropertyTreeBuilderContext& context) { |
983 if (!object.isBoxModelObject() && !object.isSVG()) | |
984 return; | |
985 | |
986 #if DCHECK_IS_ON() | 983 #if DCHECK_IS_ON() |
987 FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context); | 984 FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context); |
988 #endif | 985 #endif |
989 | 986 |
990 updatePaintOffsetTranslation(object, context); | 987 if (object.isBoxModelObject() || object.isSVG()) { |
991 updateTransform(object, context); | 988 updatePaintOffsetTranslation(object, context); |
992 updateEffect(object, context); | 989 updateTransform(object, context); |
993 updateCssClip(object, context); | 990 updateEffect(object, context); |
994 updateLocalBorderBoxContext(object, context); | 991 updateCssClip(object, context); |
995 updateScrollbarPaintOffset(object, context); | 992 updateLocalBorderBoxContext(object, context); |
| 993 updateScrollbarPaintOffset(object, context); |
| 994 } |
| 995 |
| 996 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) |
| 997 object.getMutableForPainting().setPaintOffset(context.current.paintOffset); |
996 } | 998 } |
997 | 999 |
998 void PaintPropertyTreeBuilder::updatePropertiesForChildren( | 1000 void PaintPropertyTreeBuilder::updatePropertiesForChildren( |
999 const LayoutObject& object, | 1001 const LayoutObject& object, |
1000 PaintPropertyTreeBuilderContext& context) { | 1002 PaintPropertyTreeBuilderContext& context) { |
1001 if (!object.isBoxModelObject() && !object.isSVG()) | |
1002 return; | |
1003 | |
1004 #if DCHECK_IS_ON() | 1003 #if DCHECK_IS_ON() |
1005 FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context); | 1004 FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context); |
1006 #endif | 1005 #endif |
1007 | 1006 |
| 1007 if (!object.isBoxModelObject() && !object.isSVG()) |
| 1008 return; |
| 1009 |
1008 updateOverflowClip(object, context); | 1010 updateOverflowClip(object, context); |
1009 updatePerspective(object, context); | 1011 updatePerspective(object, context); |
1010 updateSvgLocalToBorderBoxTransform(object, context); | 1012 updateSvgLocalToBorderBoxTransform(object, context); |
1011 updateScrollAndScrollTranslation(object, context); | 1013 updateScrollAndScrollTranslation(object, context); |
1012 updateOutOfFlowContext(object, context); | 1014 updateOutOfFlowContext(object, context); |
1013 | 1015 |
1014 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 1016 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
1015 } | 1017 } |
1016 | 1018 |
1017 } // namespace blink | 1019 } // namespace blink |
OLD | NEW |