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