Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 #include "core/dom/DOMNodeIds.h" | 8 #include "core/dom/DOMNodeIds.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1036 // Similar adjustment is done in LayoutTableCell::offsetFromContainer(). | 1036 // Similar adjustment is done in LayoutTableCell::offsetFromContainer(). |
| 1037 if (object.isTableCell()) { | 1037 if (object.isTableCell()) { |
| 1038 LayoutObject* parentRow = object.parent(); | 1038 LayoutObject* parentRow = object.parent(); |
| 1039 DCHECK(parentRow && parentRow->isTableRow()); | 1039 DCHECK(parentRow && parentRow->isTableRow()); |
| 1040 context.current.paintOffset.moveBy( | 1040 context.current.paintOffset.moveBy( |
| 1041 -toLayoutBox(parentRow)->physicalLocation()); | 1041 -toLayoutBox(parentRow)->physicalLocation()); |
| 1042 } | 1042 } |
| 1043 } | 1043 } |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 void PaintPropertyTreeBuilder::updateForObjectLocation( | 1046 void PaintPropertyTreeBuilder::updateForObjectSizeAndLocation( |
| 1047 const LayoutObject& object, | 1047 const LayoutObject& object, |
| 1048 PaintPropertyTreeBuilderContext& context) { | 1048 PaintPropertyTreeBuilderContext& context) { |
| 1049 if (object.isBoxModelObject()) { | 1049 if (object.isBoxModelObject()) { |
| 1050 updatePaintOffset(toLayoutBoxModelObject(object), context); | 1050 updatePaintOffset(toLayoutBoxModelObject(object), context); |
| 1051 updatePaintOffsetTranslation(toLayoutBoxModelObject(object), context); | 1051 updatePaintOffsetTranslation(toLayoutBoxModelObject(object), context); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 if (object.paintOffset() == context.current.paintOffset) | 1054 if (object.isBox()) { |
| 1055 return; | 1055 const LayoutBox& box = toLayoutBox(object); |
| 1056 if (box.size() != box.previousSize() && | |
| 1057 // The overflow clip paint property depends on the border box rect | |
| 1058 // through overflowClipRect(). The border box rect's size equals the | |
| 1059 // frame rect's size so we trigger a paint property update when the | |
| 1060 // frame rect changes. | |
| 1061 (box.shouldClipOverflow() || | |
| 1062 // The used value of CSS clip may depend on size of the box, e.g. | |
| 1063 // for clip: rect(auto auto auto -5px). | |
| 1064 box.hasClip() || | |
| 1065 // Relative lengths (e.g., percentage values) in transform, | |
| 1066 // perspective, transform-origin, and perspective-origin can depend on | |
| 1067 // the size of the frame rect, so force a property update if it | |
| 1068 // changes. TODO(pdr): We only need to update properties if there are | |
| 1069 // relative lengths. | |
| 1070 box.styleRef().hasTransform() || box.styleRef().hasPerspective())) | |
| 1071 box.getMutableForPainting().setNeedsPaintPropertyUpdate(); | |
| 1072 } | |
| 1056 | 1073 |
| 1057 // Many paint properties depend on paint offset so we force an update of | 1074 if (object.paintOffset() != context.current.paintOffset) { |
| 1058 // the entire subtree on paint offset changes. | 1075 // Many paint properties depend on paint offset so we force an update of |
| 1059 context.forceSubtreeUpdate = true; | 1076 // the entire subtree on paint offset changes. |
| 1077 context.forceSubtreeUpdate = true; | |
| 1060 | 1078 |
| 1061 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1079 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1062 object.getMutableForPainting().setShouldDoFullPaintInvalidation( | 1080 object.getMutableForPainting().setShouldDoFullPaintInvalidation( |
| 1063 PaintInvalidationLocationChange); | 1081 PaintInvalidationLocationChange); |
| 1082 } | |
| 1083 object.getMutableForPainting().setPaintOffset(context.current.paintOffset); | |
| 1064 } | 1084 } |
| 1065 object.getMutableForPainting().setPaintOffset(context.current.paintOffset); | |
| 1066 } | 1085 } |
| 1067 | 1086 |
| 1068 void PaintPropertyTreeBuilder::updatePropertiesForSelf( | 1087 void PaintPropertyTreeBuilder::updatePropertiesForSelf( |
| 1069 const LayoutObject& object, | 1088 const LayoutObject& object, |
| 1070 PaintPropertyTreeBuilderContext& context) { | 1089 PaintPropertyTreeBuilderContext& context) { |
| 1071 // This is not in FindObjectPropertiesNeedingUpdateScope because paint offset | 1090 // This is not in FindObjectPropertiesNeedingUpdateScope because paint offset |
| 1072 // can change without needsPaintPropertyUpdate. | 1091 // can change without needsPaintPropertyUpdate. |
|
pdr.
2017/03/01 23:38:38
Nit: can you mention size changing in this comment
| |
| 1073 updateForObjectLocation(object, context); | 1092 updateForObjectSizeAndLocation(object, context); |
| 1074 | 1093 |
| 1075 #if DCHECK_IS_ON() | 1094 #if DCHECK_IS_ON() |
| 1076 FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context); | 1095 FindObjectPropertiesNeedingUpdateScope checkNeedsUpdateScope(object, context); |
| 1077 #endif | 1096 #endif |
| 1078 | 1097 |
| 1079 if (object.isBoxModelObject() || object.isSVG()) { | 1098 if (object.isBoxModelObject() || object.isSVG()) { |
| 1080 updateTransform(object, context); | 1099 updateTransform(object, context); |
| 1081 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1100 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1082 updateEffect(object, context); | 1101 updateEffect(object, context); |
| 1083 updateFilter(object, context); | 1102 updateFilter(object, context); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1102 updateOverflowClip(object, context); | 1121 updateOverflowClip(object, context); |
| 1103 updatePerspective(object, context); | 1122 updatePerspective(object, context); |
| 1104 updateSvgLocalToBorderBoxTransform(object, context); | 1123 updateSvgLocalToBorderBoxTransform(object, context); |
| 1105 updateScrollAndScrollTranslation(object, context); | 1124 updateScrollAndScrollTranslation(object, context); |
| 1106 updateOutOfFlowContext(object, context); | 1125 updateOutOfFlowContext(object, context); |
| 1107 | 1126 |
| 1108 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); | 1127 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); |
| 1109 } | 1128 } |
| 1110 | 1129 |
| 1111 } // namespace blink | 1130 } // namespace blink |
| OLD | NEW |