Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/PaintInvalidator.h" | 5 #include "core/paint/PaintInvalidator.h" |
| 6 | 6 |
| 7 #include "core/editing/FrameSelection.h" | 7 #include "core/editing/FrameSelection.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" |
| 11 #include "core/layout/LayoutObject.h" | 11 #include "core/layout/LayoutObject.h" |
| 12 #include "core/layout/LayoutTable.h" | 12 #include "core/layout/LayoutTable.h" |
| 13 #include "core/layout/svg/SVGLayoutSupport.h" | 13 #include "core/layout/svg/SVGLayoutSupport.h" |
| 14 #include "core/paint/ObjectPaintProperties.h" | |
| 14 #include "core/paint/PaintLayer.h" | 15 #include "core/paint/PaintLayer.h" |
| 15 #include "core/paint/PaintLayerScrollableArea.h" | 16 #include "core/paint/PaintLayerScrollableArea.h" |
| 17 #include "core/paint/PaintPropertyTreeBuilder.h" | |
| 16 | 18 |
| 17 namespace blink { | 19 namespace blink { |
| 18 | 20 |
| 19 void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking(const Layou tObject& object, LayoutRect& rect) const | 21 // TODO(wangxianzhu): Combine this into PaintInvalidator::mapLocalRectToPaintInv alidationBacking() when removing PaintInvalidationState. |
| 22 static LayoutRect mapLocalRectToPaintInvalidationBacking(GeometryMapper& geometr yMapper, const LayoutObject& object, const FloatRect& localRect, const PaintInva lidatorContext& context) | |
| 20 { | 23 { |
| 21 // TODO(wangxianzhu): For now this is the same as the slow path in PaintInva lidationState.cpp | 24 // TODO(wkorman): The flip below is required because visual rects are |
| 22 // (slowMapToVisualRectInAncestorSpace()). Should implement this with Geomet ryMapper. | 25 // currently in "physical coordinates with flipped block-flow direction" |
| 26 // (see LayoutBoxModelObject.h) but we need them to be in physical | |
| 27 // coordinates. | |
| 28 FloatRect rect = localRect; | |
| 23 if (object.isBox()) | 29 if (object.isBox()) |
| 24 toLayoutBox(object).flipForWritingMode(rect); | 30 toLayoutBox(object).flipForWritingMode(rect); |
| 25 | 31 |
| 26 if (object.isLayoutView()) | 32 LayoutRect result; |
| 27 toLayoutView(object).mapToVisualRectInAncestorSpace(paintInvalidationCon tainer, rect, InputIsInFrameCoordinates, DefaultVisualRectFlags); | 33 if (object == context.paintInvalidationContainer) { |
| 28 else | 34 result = LayoutRect(rect); |
| 29 object.mapToVisualRectInAncestorSpace(paintInvalidationContainer, rect); | 35 } else { |
| 36 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); | |
| 37 | |
| 38 bool success = false; | |
| 39 PropertyTreeState currentTreeState(context.treeBuilderContext.current.tr ansform, context.treeBuilderContext.current.clip, context.treeBuilderContext.cur rentEffect); | |
| 40 const PropertyTreeState& containerTreeState = context.paintInvalidationC ontainer->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState ; | |
| 41 result = LayoutRect(GeometryMapper().mapToVisualRectInDestinationSpace(r ect, currentTreeState, containerTreeState, success)); | |
| 42 DCHECK(success); | |
| 43 } | |
| 44 | |
| 45 if (context.paintInvalidationContainer->layer()->groupedMapping()) | |
| 46 PaintLayer::mapRectInPaintInvalidationContainerToBacking(*context.paintI nvalidationContainer, result); | |
| 47 return result; | |
| 30 } | 48 } |
| 31 | 49 |
| 32 static LayoutRect computePaintInvalidationRectInBacking(const LayoutObject& obje ct, const PaintInvalidatorContext& context) | 50 void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking(const Layou tObject& object, LayoutRect& rect) const |
| 33 { | 51 { |
| 34 if (object.isSVG() && !object.isSVGRoot()) { | 52 GeometryMapper geometryMapper; |
| 35 // TODO(wangxianzhu): For now this is the same as the slow path in Paint InvalidationState.cpp | 53 rect = blink::mapLocalRectToPaintInvalidationBacking(geometryMapper, object, FloatRect(rect), *this); |
| 36 // (PaintInvalidationState::computePaintInvalidationRectInBackingForSVG( )). Should implement this with GeometryMapper. | |
| 37 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidat ion(object, *context.paintInvalidationContainer); | |
| 38 if (context.paintInvalidationContainer->layer()->groupedMapping()) | |
| 39 PaintLayer::mapRectInPaintInvalidationContainerToBacking(*context.pa intInvalidationContainer, rect); | |
| 40 return rect; | |
| 41 } | |
| 42 | |
| 43 LayoutRect rect = object.localOverflowRectForPaintInvalidation(); | |
| 44 context.mapLocalRectToPaintInvalidationBacking(object, rect); | |
| 45 return rect; | |
| 46 } | 54 } |
| 47 | 55 |
| 48 static LayoutPoint computeLocationFromPaintInvalidationBacking(const LayoutObjec t& object, const PaintInvalidatorContext& context) | 56 LayoutRect PaintInvalidator::mapLocalRectToPaintInvalidationBacking(const Layout Object& object, const FloatRect& localRect, const PaintInvalidatorContext& conte xt) |
| 49 { | 57 { |
| 50 // TODO(wangxianzhu): For now this is the same as the slow path in PaintInva lidationState.cpp | 58 return blink::mapLocalRectToPaintInvalidationBacking(m_geometryMapper, objec t, localRect, context); |
| 51 // (slowLocalToAncestorPoint()). Should implement this with GeometryMapper. | 59 } |
| 60 | |
| 61 LayoutRect PaintInvalidator::computePaintInvalidationRectInBacking(const LayoutO bject& object, const PaintInvalidatorContext& context) | |
| 62 { | |
| 63 FloatRect localRect; | |
| 64 if (object.isSVG() && !object.isSVGRoot()) | |
| 65 localRect = SVGLayoutSupport::localOverflowRectForPaintInvalidation(obje ct); | |
| 66 else | |
| 67 localRect = FloatRect(object.localOverflowRectForPaintInvalidation()); | |
| 68 | |
| 69 return mapLocalRectToPaintInvalidationBacking(object, localRect, context); | |
| 70 } | |
| 71 | |
| 72 LayoutPoint PaintInvalidator::computeLocationFromPaintInvalidationBacking(const LayoutObject& object, const PaintInvalidatorContext& context) | |
| 73 { | |
| 52 FloatPoint point; | 74 FloatPoint point; |
| 53 if (object != context.paintInvalidationContainer) { | 75 if (object != context.paintInvalidationContainer) { |
| 54 if (object.isLayoutView()) { | 76 point.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)) ; |
| 55 point = toLayoutView(object).localToAncestorPoint(point, context.pai ntInvalidationContainer, TraverseDocumentBoundaries | InputIsInFrameCoordinates) ; | 77 |
| 56 } else { | 78 bool success = false; |
| 57 point = object.localToAncestorPoint(point, context.paintInvalidation Container, TraverseDocumentBoundaries); | 79 PropertyTreeState currentTreeState(context.treeBuilderContext.current.tr ansform, context.treeBuilderContext.current.clip, context.treeBuilderContext.cur rentEffect); |
| 58 // Paint invalidation does not include scroll of paintInvalidationCo ntainer. | 80 const PropertyTreeState& containerTreeState = context.paintInvalidationC ontainer->objectPaintProperties()->localBorderBoxProperties()->propertyTreeState ; |
| 59 if (context.paintInvalidationContainer->isBox()) { | 81 point = GeometryMapper().mapRectToDestinationSpace(FloatRect(point, Floa tSize()), currentTreeState, containerTreeState, success).location(); |
|
chrishtr
2016/08/12 19:46:11
What about this one?
Xianzhu
2016/08/13 00:51:16
Sorry, missed this one. Change to m_geometryMapper
| |
| 60 const LayoutBox* box = toLayoutBox(context.paintInvalidationCont ainer); | 82 DCHECK(success); |
| 61 if (box->hasOverflowClip()) | |
| 62 point.move(box->scrolledContentOffset()); | |
| 63 } | |
| 64 } | |
| 65 } | 83 } |
| 66 | 84 |
| 67 | |
| 68 if (context.paintInvalidationContainer->layer()->groupedMapping()) | 85 if (context.paintInvalidationContainer->layer()->groupedMapping()) |
| 69 PaintLayer::mapPointInPaintInvalidationContainerToBacking(*context.paint InvalidationContainer, point); | 86 PaintLayer::mapPointInPaintInvalidationContainerToBacking(*context.paint InvalidationContainer, point); |
| 70 | 87 |
| 71 return LayoutPoint(point); | 88 return LayoutPoint(point); |
| 72 } | 89 } |
| 73 | 90 |
| 74 static void updatePaintingLayer(const LayoutObject& object, PaintInvalidatorCont ext& context) | 91 void PaintInvalidator::updatePaintingLayer(const LayoutObject& object, PaintInva lidatorContext& context) |
| 75 { | 92 { |
| 76 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingLayer ()) | 93 if (object.hasLayer() && toLayoutBoxModelObject(object).hasSelfPaintingLayer ()) |
| 77 context.paintingLayer = toLayoutBoxModelObject(object).layer(); | 94 context.paintingLayer = toLayoutBoxModelObject(object).layer(); |
| 78 | 95 |
| 79 if (object.isLayoutBlockFlow() && toLayoutBlockFlow(object).containsFloats() ) | 96 if (object.isLayoutBlockFlow() && toLayoutBlockFlow(object).containsFloats() ) |
| 80 context.paintingLayer->setNeedsPaintPhaseFloat(); | 97 context.paintingLayer->setNeedsPaintPhaseFloat(); |
| 81 | 98 |
| 82 if (object == context.paintingLayer->layoutObject()) | 99 if (object == context.paintingLayer->layoutObject()) |
| 83 return; | 100 return; |
| 84 | 101 |
| 85 if (object.styleRef().hasOutline()) | 102 if (object.styleRef().hasOutline()) |
| 86 context.paintingLayer->setNeedsPaintPhaseDescendantOutlines(); | 103 context.paintingLayer->setNeedsPaintPhaseDescendantOutlines(); |
| 87 | 104 |
| 88 if (object.hasBoxDecorationBackground() | 105 if (object.hasBoxDecorationBackground() |
| 89 // We also paint overflow controls in background phase. | 106 // We also paint overflow controls in background phase. |
| 90 || (object.hasOverflowClip() && toLayoutBox(object).getScrollableArea()- >hasOverflowControls())) { | 107 || (object.hasOverflowClip() && toLayoutBox(object).getScrollableArea()- >hasOverflowControls())) { |
| 91 context.paintingLayer->setNeedsPaintPhaseDescendantBlockBackgrounds(); | 108 context.paintingLayer->setNeedsPaintPhaseDescendantBlockBackgrounds(); |
| 92 } | 109 } |
| 93 | 110 |
| 94 if (object.isTable()) { | 111 if (object.isTable()) { |
| 95 const LayoutTable& table = toLayoutTable(object); | 112 const LayoutTable& table = toLayoutTable(object); |
| 96 if (table.collapseBorders() && !table.collapsedBorders().isEmpty()) | 113 if (table.collapseBorders() && !table.collapsedBorders().isEmpty()) |
| 97 context.paintingLayer->setNeedsPaintPhaseDescendantBlockBackgrounds( ); | 114 context.paintingLayer->setNeedsPaintPhaseDescendantBlockBackgrounds( ); |
| 98 } | 115 } |
| 99 } | 116 } |
| 100 | 117 |
| 101 static void updateContext(const LayoutObject& object, PaintInvalidatorContext& c ontext) | 118 void PaintInvalidator::updateContext(const LayoutObject& object, PaintInvalidato rContext& context) |
| 102 { | 119 { |
| 103 if (object.isPaintInvalidationContainer()) { | 120 if (object.isPaintInvalidationContainer()) { |
| 104 context.paintInvalidationContainer = toLayoutBoxModelObject(&object); | 121 context.paintInvalidationContainer = toLayoutBoxModelObject(&object); |
| 105 if (object.styleRef().isStackingContext()) | 122 if (object.styleRef().isStackingContext()) |
| 106 context.paintInvalidationContainerForStackedContents = toLayoutBoxMo delObject(&object); | 123 context.paintInvalidationContainerForStackedContents = toLayoutBoxMo delObject(&object); |
| 107 } else if (object.isLayoutView()) { | 124 } else if (object.isLayoutView()) { |
| 108 // paintInvalidationContainerForStackedContents is only for stacked desc endants in its own frame, | 125 // paintInvalidationContainerForStackedContents is only for stacked desc endants in its own frame, |
| 109 // because it doesn't establish stacking context for stacked contents in sub-frames. | 126 // because it doesn't establish stacking context for stacked contents in sub-frames. |
| 110 // Contents stacked in the root stacking context in this frame should us e this frame's paintInvalidationContainer. | 127 // Contents stacked in the root stacking context in this frame should us e this frame's paintInvalidationContainer. |
| 111 context.paintInvalidationContainerForStackedContents = context.paintInva lidationContainer; | 128 context.paintInvalidationContainerForStackedContents = context.paintInva lidationContainer; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 object.getMutableForPainting().clearPaintInvalidationFlags(); | 232 object.getMutableForPainting().clearPaintInvalidationFlags(); |
| 216 } | 233 } |
| 217 | 234 |
| 218 void PaintInvalidator::processPendingDelayedPaintInvalidations() | 235 void PaintInvalidator::processPendingDelayedPaintInvalidations() |
| 219 { | 236 { |
| 220 for (auto target : m_pendingDelayedPaintInvalidations) | 237 for (auto target : m_pendingDelayedPaintInvalidations) |
| 221 target->getMutableForPainting().setShouldDoFullPaintInvalidation(PaintIn validationDelayedFull); | 238 target->getMutableForPainting().setShouldDoFullPaintInvalidation(PaintIn validationDelayedFull); |
| 222 } | 239 } |
| 223 | 240 |
| 224 } // namespace blink | 241 } // namespace blink |
| OLD | NEW |