| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/layout/PaintInvalidationState.h" | 5 #include "core/layout/PaintInvalidationState.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
| 9 #include "core/layout/LayoutInline.h" | 9 #include "core/layout/LayoutInline.h" |
| 10 #include "core/layout/LayoutPart.h" | 10 #include "core/layout/LayoutPart.h" |
| 11 #include "core/layout/LayoutView.h" | 11 #include "core/layout/LayoutView.h" |
| 12 #include "core/layout/svg/LayoutSVGModelObject.h" | 12 #include "core/layout/svg/LayoutSVGModelObject.h" |
| 13 #include "core/layout/svg/LayoutSVGRoot.h" | 13 #include "core/layout/svg/LayoutSVGRoot.h" |
| 14 #include "core/layout/svg/SVGLayoutSupport.h" | 14 #include "core/layout/svg/SVGLayoutSupport.h" |
| 15 #include "core/paint/PaintLayer.h" | 15 #include "core/paint/PaintLayer.h" |
| 16 | 16 |
| 17 // We can't enable this by default because saturated operations of LayoutUnit | 17 // We can't enable this by default because saturated operations of LayoutUnit |
| 18 // don't conform commutative law for overflowing results, preventing us from | 18 // don't conform commutative law for overflowing results, preventing us from |
| 19 // making fast-path and slow-path always return the same result. | 19 // making fast-path and slow-path always return the same result. |
| 20 #define ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH (0 && ENABLE(ASSERT)) | 20 #define ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH (0 && ENABLE(ASSERT)) |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | 23 |
| 24 static bool isAbsolutePositionUnderRelativePositionInline(const LayoutObject& ob
ject) | |
| 25 { | |
| 26 if (object.styleRef().position() != AbsolutePosition) | |
| 27 return false; | |
| 28 if (LayoutObject* container = object.container()) | |
| 29 return container->isAnonymousBlock() && container->styleRef().position()
== RelativePosition; | |
| 30 return false; | |
| 31 } | |
| 32 | |
| 33 static bool supportsCachedOffsets(const LayoutObject& object) | 24 static bool supportsCachedOffsets(const LayoutObject& object) |
| 34 { | 25 { |
| 35 // TODO(wangxianzhu): Move some conditions to fast path if possible. | |
| 36 return !object.hasTransformRelatedProperty() | 26 return !object.hasTransformRelatedProperty() |
| 37 && !object.hasReflection() | 27 && !object.hasReflection() |
| 38 && !object.hasFilter() | 28 && !object.hasFilter() |
| 39 && !object.isLayoutFlowThread() | 29 && !object.isLayoutFlowThread() |
| 40 && !object.isLayoutMultiColumnSpannerPlaceholder() | 30 && !object.isLayoutMultiColumnSpannerPlaceholder() |
| 41 && object.styleRef().position() != FixedPosition | |
| 42 && !object.styleRef().isFlippedBlocksWritingMode() | 31 && !object.styleRef().isFlippedBlocksWritingMode() |
| 43 // TODO(crbug.com/598094): Handle this in fast path. | 32 && !(object.isLayoutBlock() && object.isSVG()); |
| 44 && !isAbsolutePositionUnderRelativePositionInline(object); | |
| 45 } | 33 } |
| 46 | 34 |
| 47 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec
tor<LayoutObject*>& pendingDelayedPaintInvalidations) | 35 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec
tor<LayoutObject*>& pendingDelayedPaintInvalidations) |
| 48 : m_currentObject(layoutView) | 36 : m_currentObject(layoutView) |
| 49 , m_clipped(false) | |
| 50 , m_cachedOffsetsEnabled(true) | |
| 51 , m_forcedSubtreeInvalidationWithinContainer(false) | 37 , m_forcedSubtreeInvalidationWithinContainer(false) |
| 52 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) | 38 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) |
| 53 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation()) | 39 , m_clipped(false) |
| 40 , m_clippedForAbsolutePosition(false) |
| 41 , m_cachedOffsetsEnabled(true) |
| 42 , m_cachedOffsetsForAbsolutePositionEnabled(true) |
| 43 , m_paintInvalidationContainer(&layoutView.containerForPaintInvalidation()) |
| 44 , m_paintInvalidationContainerForStackedContents(m_paintInvalidationContaine
r) |
| 45 , m_containerForAbsolutePosition(layoutView) |
| 54 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) | 46 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) |
| 55 , m_enclosingSelfPaintingLayer(*layoutView.layer()) | 47 , m_enclosingSelfPaintingLayer(*layoutView.layer()) |
| 56 #if ENABLE(ASSERT) | 48 #if ENABLE(ASSERT) |
| 57 , m_didUpdateForChildren(false) | 49 , m_didUpdateForChildren(false) |
| 58 #endif | 50 #endif |
| 59 { | 51 { |
| 60 if (!supportsCachedOffsets(layoutView)) { | 52 if (!supportsCachedOffsets(layoutView)) { |
| 61 m_cachedOffsetsEnabled = false; | 53 m_cachedOffsetsEnabled = false; |
| 62 return; | 54 return; |
| 63 } | 55 } |
| 64 | 56 |
| 65 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_paintInv
alidationContainer, TraverseDocumentBoundaries | InputIsInFrameCoordinates); | 57 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), m_paintInva
lidationContainer, TraverseDocumentBoundaries | InputIsInFrameCoordinates); |
| 66 m_paintOffset = LayoutSize(point.x(), point.y()); | 58 m_paintOffset = LayoutSize(point.x(), point.y()); |
| 67 } | 59 m_paintOffsetForAbsolutePosition = m_paintOffset; |
| 68 | |
| 69 // TODO(wangxianzhu): This is temporary for positioned object whose paintInvalid
ationContainer is different from | |
| 70 // the one we find during tree walk. Remove this after we fix the issue with tre
e walk in DOM-order. | |
| 71 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par
entState, const LayoutBoxModelObject& currentObject, const LayoutBoxModelObject&
paintInvalidationContainer) | |
| 72 : m_currentObject(currentObject) | |
| 73 , m_clipped(parentState.m_clipped) | |
| 74 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) | |
| 75 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva
lidationWithinContainer) | |
| 76 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS
ubtreeInvalidationRectUpdateWithinContainer) | |
| 77 , m_clipRect(parentState.m_clipRect) | |
| 78 , m_paintOffset(parentState.m_paintOffset) | |
| 79 , m_paintInvalidationContainer(paintInvalidationContainer) | |
| 80 , m_svgTransform(parentState.m_svgTransform) | |
| 81 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida
tionTargets()) | |
| 82 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren
tObject)) | |
| 83 #if ENABLE(ASSERT) | |
| 84 , m_didUpdateForChildren(true) | |
| 85 #endif | |
| 86 { | |
| 87 ASSERT(parentState.m_didUpdateForChildren); | |
| 88 ASSERT(!m_cachedOffsetsEnabled); | |
| 89 } | 60 } |
| 90 | 61 |
| 91 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par
entState, const LayoutObject& currentObject) | 62 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par
entState, const LayoutObject& currentObject) |
| 92 : m_currentObject(currentObject) | 63 : m_currentObject(currentObject) |
| 93 , m_clipped(parentState.m_clipped) | |
| 94 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) | |
| 95 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva
lidationWithinContainer) | 64 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva
lidationWithinContainer) |
| 96 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS
ubtreeInvalidationRectUpdateWithinContainer) | 65 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS
ubtreeInvalidationRectUpdateWithinContainer) |
| 66 , m_clipped(parentState.m_clipped) |
| 67 , m_clippedForAbsolutePosition(parentState.m_clippedForAbsolutePosition) |
| 97 , m_clipRect(parentState.m_clipRect) | 68 , m_clipRect(parentState.m_clipRect) |
| 69 , m_clipRectForAbsolutePosition(parentState.m_clipRectForAbsolutePosition) |
| 98 , m_paintOffset(parentState.m_paintOffset) | 70 , m_paintOffset(parentState.m_paintOffset) |
| 99 , m_paintInvalidationContainer(currentObject.isPaintInvalidationContainer()
? toLayoutBoxModelObject(currentObject) : parentState.m_paintInvalidationContain
er) | 71 , m_paintOffsetForAbsolutePosition(parentState.m_paintOffsetForAbsolutePosit
ion) |
| 72 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) |
| 73 , m_cachedOffsetsForAbsolutePositionEnabled(parentState.m_cachedOffsetsForAb
solutePositionEnabled) |
| 74 , m_paintInvalidationContainer(parentState.m_paintInvalidationContainer) |
| 75 , m_paintInvalidationContainerForStackedContents(parentState.m_paintInvalida
tionContainerForStackedContents) |
| 76 , m_containerForAbsolutePosition(currentObject.canContainAbsolutePositionObj
ects() ? currentObject : parentState.m_containerForAbsolutePosition) |
| 100 , m_svgTransform(parentState.m_svgTransform) | 77 , m_svgTransform(parentState.m_svgTransform) |
| 101 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida
tionTargets()) | 78 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida
tionTargets()) |
| 102 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren
tObject)) | 79 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren
tObject)) |
| 103 #if ENABLE(ASSERT) | 80 #if ENABLE(ASSERT) |
| 104 , m_didUpdateForChildren(false) | 81 , m_didUpdateForChildren(false) |
| 105 #endif | 82 #endif |
| 106 { | 83 { |
| 107 if (currentObject == parentState.m_currentObject) { | 84 if (currentObject == parentState.m_currentObject) { |
| 108 // Sometimes we create a new PaintInvalidationState from parentState on
the same object | 85 // Sometimes we create a new PaintInvalidationState from parentState on
the same object |
| 109 // (e.g. LayoutView, and the HorriblySlowRectMapping cases in LayoutBloc
k::invalidatePaintOfSubtreesIfNeeded()). | 86 // (e.g. LayoutView, and the HorriblySlowRectMapping cases in LayoutBloc
k::invalidatePaintOfSubtreesIfNeeded()). |
| 110 // TODO(wangxianzhu): Avoid this for RuntimeEnabledFeatures::slimmingPai
ntInvalidationEnabled(). | 87 // TODO(wangxianzhu): Avoid this for RuntimeEnabledFeatures::slimmingPai
ntInvalidationEnabled(). |
| 111 #if ENABLE(ASSERT) | 88 #if ENABLE(ASSERT) |
| 112 m_didUpdateForChildren = parentState.m_didUpdateForChildren; | 89 m_didUpdateForChildren = parentState.m_didUpdateForChildren; |
| 113 #endif | 90 #endif |
| 114 return; | 91 return; |
| 115 } | 92 } |
| 116 | 93 |
| 117 ASSERT(parentState.m_didUpdateForChildren); | 94 ASSERT(parentState.m_didUpdateForChildren); |
| 118 | 95 |
| 96 EPosition position = currentObject.styleRef().position(); |
| 97 |
| 98 if (currentObject.isPaintInvalidationContainer()) { |
| 99 m_paintInvalidationContainer = toLayoutBoxModelObject(¤tObject); |
| 100 if (currentObject.styleRef().isStackingContext()) { |
| 101 m_paintInvalidationContainerForStackedContents = toLayoutBoxModelObj
ect(¤tObject); |
| 102 |
| 103 // Disable cached offsets for absolute-position objects if this obje
ct is not a container for |
| 104 // absolute-position because absolute-position objects' locations ar
e determined by something |
| 105 // above their paint invalidation container. |
| 106 if (m_currentObject != m_containerForAbsolutePosition) |
| 107 m_cachedOffsetsForAbsolutePositionEnabled = false; |
| 108 } |
| 109 } else if (currentObject.isLayoutView()) { |
| 110 // m_paintInvalidationContainerForStackedContents doesn't cross frame bo
undary. |
| 111 m_paintInvalidationContainerForStackedContents = m_paintInvalidationCont
ainer; |
| 112 } else if (currentObject.styleRef().isStacked() |
| 113 // This is to exclude some objects (e.g. LayoutText) inheriting stacked
style from parent but aren't actually stacked. |
| 114 && currentObject.hasLayer() |
| 115 && m_paintInvalidationContainer != m_paintInvalidationContainerForStacke
dContents) { |
| 116 m_paintInvalidationContainer = m_paintInvalidationContainerForStackedCon
tents; |
| 117 // We are changing paint invalidation container, but didn't track paint
offset from |
| 118 // m_paintInvalidationContainerForStackedContents, so disable cached off
sets. |
| 119 m_cachedOffsetsEnabled = false; |
| 120 } |
| 121 |
| 119 if (!currentObject.isBoxModelObject() && !currentObject.isSVG()) | 122 if (!currentObject.isBoxModelObject() && !currentObject.isSVG()) |
| 120 return; | 123 return; |
| 121 | 124 |
| 122 if (m_cachedOffsetsEnabled && !supportsCachedOffsets(currentObject)) | 125 if (m_cachedOffsetsEnabled || currentObject == m_paintInvalidationContainer) |
| 123 m_cachedOffsetsEnabled = false; | 126 m_cachedOffsetsEnabled = !supportsCachedOffsets(currentObject); |
| 124 | 127 |
| 125 if (currentObject.isSVG()) { | 128 if (currentObject.isSVG()) { |
| 126 if (currentObject.isSVGRoot()) { | 129 if (currentObject.isSVGRoot()) { |
| 127 m_svgTransform = toLayoutSVGRoot(currentObject).localToBorderBoxTran
sform(); | 130 m_svgTransform = toLayoutSVGRoot(currentObject).localToBorderBoxTran
sform(); |
| 128 // Don't early return here, because the SVGRoot object needs to exec
ute the later code | 131 // Don't early return here, because the SVGRoot object needs to exec
ute the later code |
| 129 // as a normal LayoutBox. | 132 // as a normal LayoutBox. |
| 130 } else { | 133 } else { |
| 131 ASSERT(currentObject != m_paintInvalidationContainer); | 134 ASSERT(currentObject != m_paintInvalidationContainer); |
| 132 m_svgTransform *= currentObject.localToSVGParentTransform(); | 135 m_svgTransform *= currentObject.localToSVGParentTransform(); |
| 133 return; | 136 return; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 149 | 152 |
| 150 if (!m_cachedOffsetsEnabled) | 153 if (!m_cachedOffsetsEnabled) |
| 151 return; | 154 return; |
| 152 | 155 |
| 153 if (currentObject.isLayoutView()) { | 156 if (currentObject.isLayoutView()) { |
| 154 ASSERT(&parentState.m_currentObject == toLayoutView(currentObject).frame
()->ownerLayoutObject()); | 157 ASSERT(&parentState.m_currentObject == toLayoutView(currentObject).frame
()->ownerLayoutObject()); |
| 155 m_paintOffset += toLayoutBox(parentState.m_currentObject).contentBoxOffs
et(); | 158 m_paintOffset += toLayoutBox(parentState.m_currentObject).contentBoxOffs
et(); |
| 156 return; | 159 return; |
| 157 } | 160 } |
| 158 | 161 |
| 162 if (position == FixedPosition) { |
| 163 if (m_paintInvalidationContainer != currentObject.view() && m_paintInval
idationContainer->view() == currentObject.view()) { |
| 164 // TODO(crbug.com/598762): localToAncestorPoint() is incorrect for f
ixed-position when paintInvalidationContainer |
| 165 // is under the containing LayoutView. |
| 166 m_cachedOffsetsEnabled = false; |
| 167 return; |
| 168 } |
| 169 FloatPoint fixedOffset = currentObject.localToAncestorPoint(FloatPoint()
, m_paintInvalidationContainer, TraverseDocumentBoundaries); |
| 170 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); |
| 171 // Ancestor clippings are ignored for simplicity. |
| 172 m_clipped = false; |
| 173 return; |
| 174 } |
| 175 |
| 176 if (position == AbsolutePosition) { |
| 177 m_cachedOffsetsEnabled = m_cachedOffsetsForAbsolutePositionEnabled; |
| 178 if (!m_cachedOffsetsEnabled) |
| 179 return; |
| 180 |
| 181 m_paintOffset = m_paintOffsetForAbsolutePosition; |
| 182 m_clipped = m_clippedForAbsolutePosition; |
| 183 m_clipRect = m_clipRectForAbsolutePosition; |
| 184 |
| 185 const LayoutObject& container = parentState.m_containerForAbsolutePositi
on; |
| 186 if (container.isInFlowPositioned() && container.isLayoutInline()) |
| 187 m_paintOffset += toLayoutInline(container).offsetForInFlowPositioned
Inline(toLayoutBox(m_currentObject)); |
| 188 } |
| 189 |
| 159 if (currentObject.isBox()) | 190 if (currentObject.isBox()) |
| 160 m_paintOffset += toLayoutBox(currentObject).locationOffset(); | 191 m_paintOffset += toLayoutBox(currentObject).locationOffset(); |
| 161 | 192 |
| 162 if (currentObject.isInFlowPositioned() && currentObject.hasLayer()) | 193 if (currentObject.isInFlowPositioned() && currentObject.hasLayer()) |
| 163 m_paintOffset += toLayoutBoxModelObject(currentObject).layer()->offsetFo
rInFlowPosition(); | 194 m_paintOffset += toLayoutBoxModelObject(currentObject).layer()->offsetFo
rInFlowPosition(); |
| 164 } | 195 } |
| 165 | 196 |
| 166 void PaintInvalidationState::updateForChildren() | 197 void PaintInvalidationState::updateForChildren() |
| 167 { | 198 { |
| 168 #if ENABLE(ASSERT) | 199 #if ENABLE(ASSERT) |
| 169 ASSERT(!m_didUpdateForChildren); | 200 ASSERT(!m_didUpdateForChildren); |
| 170 m_didUpdateForChildren = true; | 201 m_didUpdateForChildren = true; |
| 171 #endif | 202 #endif |
| 172 | 203 |
| 204 updateForNormalChildren(); |
| 205 |
| 206 if (m_currentObject == m_containerForAbsolutePosition) { |
| 207 if (m_paintInvalidationContainer == m_paintInvalidationContainerForStack
edContents) { |
| 208 m_cachedOffsetsForAbsolutePositionEnabled = m_cachedOffsetsEnabled; |
| 209 if (m_cachedOffsetsEnabled) { |
| 210 m_paintOffsetForAbsolutePosition = m_paintOffset; |
| 211 m_clippedForAbsolutePosition = m_clipped; |
| 212 m_clipRectForAbsolutePosition = m_clipRect; |
| 213 } |
| 214 } else { |
| 215 m_cachedOffsetsForAbsolutePositionEnabled = false; |
| 216 } |
| 217 } |
| 218 } |
| 219 |
| 220 void PaintInvalidationState::updateForNormalChildren() |
| 221 { |
| 173 if (!m_cachedOffsetsEnabled) | 222 if (!m_cachedOffsetsEnabled) |
| 174 return; | 223 return; |
| 175 | 224 |
| 176 if (!m_currentObject.isBoxModelObject() && !m_currentObject.isSVG()) | 225 if (!m_currentObject.isBoxModelObject() && !m_currentObject.isSVG()) |
| 177 return; | 226 return; |
| 178 | 227 |
| 179 if (m_currentObject.isLayoutView()) { | 228 if (m_currentObject.isLayoutView()) { |
| 180 if (!m_currentObject.document().settings() || !m_currentObject.document(
).settings()->rootLayerScrolls()) { | 229 if (!m_currentObject.document().settings() || !m_currentObject.document(
).settings()->rootLayerScrolls()) { |
| 181 if (m_currentObject != m_paintInvalidationContainer) { | 230 if (m_currentObject != m_paintInvalidationContainer) { |
| 182 m_paintOffset -= toLayoutView(m_currentObject).frameView()->scro
llOffset(); | 231 m_paintOffset -= toLayoutView(m_currentObject).frameView()->scro
llOffset(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (object.isLayoutView()) | 264 if (object.isLayoutView()) |
| 216 return toLayoutView(object).localToAncestorPoint(point, &ancestor, Trave
rseDocumentBoundaries | InputIsInFrameCoordinates); | 265 return toLayoutView(object).localToAncestorPoint(point, &ancestor, Trave
rseDocumentBoundaries | InputIsInFrameCoordinates); |
| 217 return object.localToAncestorPoint(point, &ancestor, TraverseDocumentBoundar
ies); | 266 return object.localToAncestorPoint(point, &ancestor, TraverseDocumentBoundar
ies); |
| 218 } | 267 } |
| 219 | 268 |
| 220 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking(
) const | 269 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking(
) const |
| 221 { | 270 { |
| 222 ASSERT(!m_didUpdateForChildren); | 271 ASSERT(!m_didUpdateForChildren); |
| 223 | 272 |
| 224 FloatPoint point; | 273 FloatPoint point; |
| 225 if (m_paintInvalidationContainer != m_currentObject) { | 274 if (m_paintInvalidationContainer != &m_currentObject) { |
| 226 if (m_cachedOffsetsEnabled) { | 275 if (m_cachedOffsetsEnabled) { |
| 227 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) | 276 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) |
| 228 point = m_svgTransform.mapPoint(point); | 277 point = m_svgTransform.mapPoint(point); |
| 229 point += FloatPoint(m_paintOffset); | 278 point += FloatPoint(m_paintOffset); |
| 230 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH | 279 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH |
| 231 // TODO(wangxianzhu): We can't enable this ASSERT for now because of
crbug.com/597745. | 280 // TODO(wangxianzhu): We can't enable this ASSERT for now because of
crbug.com/597745. |
| 232 // ASSERT(point == slowLocalOriginToAncestorPoint(m_currentObject, m
_paintInvalidationContainer, FloatPoint()); | 281 // ASSERT(point == slowLocalOriginToAncestorPoint(m_currentObject, m
_paintInvalidationContainer, FloatPoint()); |
| 233 #endif | 282 #endif |
| 234 } else { | 283 } else { |
| 235 point = slowLocalToAncestorPoint(m_currentObject, m_paintInvalidatio
nContainer, FloatPoint()); | 284 point = slowLocalToAncestorPoint(m_currentObject, *m_paintInvalidati
onContainer, FloatPoint()); |
| 236 } | 285 } |
| 237 } | 286 } |
| 238 | 287 |
| 239 if (m_paintInvalidationContainer.layer()->groupedMapping()) | 288 if (m_paintInvalidationContainer->layer()->groupedMapping()) |
| 240 PaintLayer::mapPointInPaintInvalidationContainerToBacking(m_paintInvalid
ationContainer, point); | 289 PaintLayer::mapPointInPaintInvalidationContainerToBacking(*m_paintInvali
dationContainer, point); |
| 241 | 290 |
| 242 return LayoutPoint(point); | 291 return LayoutPoint(point); |
| 243 } | 292 } |
| 244 | 293 |
| 245 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBacking() const | 294 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBacking() const |
| 246 { | 295 { |
| 247 ASSERT(!m_didUpdateForChildren); | 296 ASSERT(!m_didUpdateForChildren); |
| 248 | 297 |
| 249 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) | 298 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot()) |
| 250 return computePaintInvalidationRectInBackingForSVG(); | 299 return computePaintInvalidationRectInBackingForSVG(); |
| 251 | 300 |
| 252 LayoutRect rect = m_currentObject.localOverflowRectForPaintInvalidation(); | 301 LayoutRect rect = m_currentObject.localOverflowRectForPaintInvalidation(); |
| 253 mapLocalRectToPaintInvalidationBacking(rect); | 302 mapLocalRectToPaintInvalidationBacking(rect); |
| 254 return rect; | 303 return rect; |
| 255 } | 304 } |
| 256 | 305 |
| 257 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG()
const | 306 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG()
const |
| 258 { | 307 { |
| 259 LayoutRect rect; | 308 LayoutRect rect; |
| 260 if (m_cachedOffsetsEnabled) { | 309 if (m_cachedOffsetsEnabled) { |
| 261 FloatRect svgRect = SVGLayoutSupport::localOverflowRectForPaintInvalidat
ion(m_currentObject); | 310 FloatRect svgRect = SVGLayoutSupport::localOverflowRectForPaintInvalidat
ion(m_currentObject); |
| 262 rect = SVGLayoutSupport::transformPaintInvalidationRect(m_currentObject,
m_svgTransform, svgRect); | 311 rect = SVGLayoutSupport::transformPaintInvalidationRect(m_currentObject,
m_svgTransform, svgRect); |
| 263 rect.move(m_paintOffset); | 312 rect.move(m_paintOffset); |
| 264 if (m_clipped) | 313 if (m_clipped) |
| 265 rect.intersect(m_clipRect); | 314 rect.intersect(m_clipRect); |
| 266 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH | 315 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH |
| 267 LayoutRect slowPathRect = SVGLayoutSupport::clippedOverflowRectForPaintI
nvalidation(m_currentObject, m_paintInvalidationContainer); | 316 LayoutRect slowPathRect = SVGLayoutSupport::clippedOverflowRectForPaintI
nvalidation(m_currentObject, *m_paintInvalidationContainer); |
| 268 // TODO(crbug.com/597902): Slow path misses clipping of paintInvalidatio
nContainer. | 317 // TODO(crbug.com/597902): Slow path misses clipping of paintInvalidatio
nContainer. |
| 269 if (m_clipped) | 318 if (m_clipped) |
| 270 slowPathRect.intersect(m_clipRect); | 319 slowPathRect.intersect(m_clipRect); |
| 271 // TODO(crbug.com/597903): Fast path and slow path should generate equal
empty rects. | 320 // TODO(crbug.com/597903): Fast path and slow path should generate equal
empty rects. |
| 272 ASSERT((rect.isEmpty() && slowPathRect.isEmpty()) || rect == slowPathRec
t); | 321 ASSERT((rect.isEmpty() && slowPathRect.isEmpty()) || rect == slowPathRec
t); |
| 273 #endif | 322 #endif |
| 274 } else { | 323 } else { |
| 275 // TODO(wangxianzhu): Sometimes m_cachedOffsetsEnabled==false doesn't me
an we can't use cached | 324 // TODO(wangxianzhu): Sometimes m_cachedOffsetsEnabled==false doesn't me
an we can't use cached |
| 276 // m_svgTransform. We can use hybrid fast-path (for SVG) and slow-path (
for things above the SVGRoot). | 325 // m_svgTransform. We can use hybrid fast-path (for SVG) and slow-path (
for things above the SVGRoot). |
| 277 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre
ntObject, m_paintInvalidationContainer); | 326 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre
ntObject, *m_paintInvalidationContainer); |
| 278 } | 327 } |
| 279 | 328 |
| 280 if (m_paintInvalidationContainer.layer()->groupedMapping()) | 329 if (m_paintInvalidationContainer->layer()->groupedMapping()) |
| 281 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida
tionContainer, rect); | 330 PaintLayer::mapRectInPaintInvalidationContainerToBacking(*m_paintInvalid
ationContainer, rect); |
| 282 return rect; | 331 return rect; |
| 283 } | 332 } |
| 284 | 333 |
| 285 static void slowMapToVisibleRectInAncestorSpace(const LayoutObject& object, cons
t LayoutBoxModelObject& ancestor, LayoutRect& rect) | 334 static void slowMapToVisibleRectInAncestorSpace(const LayoutObject& object, cons
t LayoutBoxModelObject& ancestor, LayoutRect& rect) |
| 286 { | 335 { |
| 287 // TODO(crbug.com/597965): LayoutBox::mapToVisibleRectInAncestorSpace() inco
rrectly flips a rect | 336 // TODO(crbug.com/597965): LayoutBox::mapToVisibleRectInAncestorSpace() inco
rrectly flips a rect |
| 288 // in its own space for writing mode. Here flip to workaround the flip. | 337 // in its own space for writing mode. Here flip to workaround the flip. |
| 289 if (object.isBox() && (toLayoutBox(object).isWritingModeRoot() || (ancestor
== object && object.styleRef().isFlippedBlocksWritingMode()))) | 338 if (object.isBox() && (toLayoutBox(object).isWritingModeRoot() || (ancestor
== object && object.styleRef().isFlippedBlocksWritingMode()))) |
| 290 toLayoutBox(object).flipForWritingMode(rect); | 339 toLayoutBox(object).flipForWritingMode(rect); |
| 291 | 340 |
| 292 if (object.isLayoutView()) { | 341 if (object.isLayoutView()) { |
| 293 toLayoutView(object).mapToVisibleRectInAncestorSpace(&ancestor, rect, In
putIsInFrameCoordinates, DefaultVisibleRectFlags); | 342 toLayoutView(object).mapToVisibleRectInAncestorSpace(&ancestor, rect, In
putIsInFrameCoordinates, DefaultVisibleRectFlags); |
| 294 } else if (object.isSVGRoot()) { | 343 } else if (object.isSVGRoot()) { |
| 295 // TODO(crbug.com/597813): This is to avoid the extra clip applied in La
youtSVGRoot::mapVisibleRectInAncestorSpace(). | 344 // TODO(crbug.com/597813): This is to avoid the extra clip applied in La
youtSVGRoot::mapVisibleRectInAncestorSpace(). |
| 296 toLayoutSVGRoot(object).LayoutReplaced::mapToVisibleRectInAncestorSpace(
&ancestor, rect); | 345 toLayoutSVGRoot(object).LayoutReplaced::mapToVisibleRectInAncestorSpace(
&ancestor, rect); |
| 297 } else { | 346 } else { |
| 298 object.mapToVisibleRectInAncestorSpace(&ancestor, rect); | 347 object.mapToVisibleRectInAncestorSpace(&ancestor, rect); |
| 299 } | 348 } |
| 300 } | 349 } |
| 301 | 350 |
| 302 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect&
rect) const | 351 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect&
rect) const |
| 303 { | 352 { |
| 304 ASSERT(!m_didUpdateForChildren); | 353 ASSERT(!m_didUpdateForChildren); |
| 305 | 354 |
| 306 if (m_cachedOffsetsEnabled) { | 355 if (m_cachedOffsetsEnabled) { |
| 307 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH | 356 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH |
| 308 LayoutRect slowPathRect(rect); | 357 LayoutRect slowPathRect(rect); |
| 309 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation
Container, slowPathRect); | 358 slowMapToVisibleRectInAncestorSpace(m_currentObject, *m_paintInvalidatio
nContainer, slowPathRect); |
| 310 #endif | 359 #endif |
| 311 rect.move(m_paintOffset); | 360 rect.move(m_paintOffset); |
| 312 if (m_clipped) | 361 if (m_clipped) |
| 313 rect.intersect(m_clipRect); | 362 rect.intersect(m_clipRect); |
| 314 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH | 363 #if ASSERT_SAME_RESULT_SLOW_AND_FAST_PATH |
| 315 // Make sure that the fast path and the slow path generate the same rect
. | 364 // Make sure that the fast path and the slow path generate the same rect
. |
| 316 // TODO(crbug.com/597902): Slow path misses clipping of paintInvalidatio
nContainer. | 365 // TODO(crbug.com/597902): Slow path misses clipping of paintInvalidatio
nContainer. |
| 317 if (m_clipped) | 366 if (m_clipped) |
| 318 slowPathRect.intersect(m_clipRect); | 367 slowPathRect.intersect(m_clipRect); |
| 319 // TODO(wangxianzhu): The isLayoutView() condition is for cases that a s
ub-frame creates a | 368 // TODO(wangxianzhu): The isLayoutView() condition is for cases that a s
ub-frame creates a |
| 320 // root PaintInvalidationState which doesn't inherit clip from ancestor
frames. | 369 // root PaintInvalidationState which doesn't inherit clip from ancestor
frames. |
| 321 // Remove the condition when we eliminate the latter case of PaintInvali
dationState(const LayoutView&, ...). | 370 // Remove the condition when we eliminate the latter case of PaintInvali
dationState(const LayoutView&, ...). |
| 371 // We ignore ancestor clipping for FixedPosition in fast path. |
| 322 // TODO(crbug.com/597903): Fast path and slow path should generate equal
empty rects. | 372 // TODO(crbug.com/597903): Fast path and slow path should generate equal
empty rects. |
| 323 ASSERT(m_currentObject.isLayoutView() || (rect.isEmpty() && slowPathRect
.isEmpty()) || rect == slowPathRect); | 373 ASSERT(m_currentObject.isLayoutView() || m_currentObject.styleRef().posi
tion() == FixedPosition || (rect.isEmpty() && slowPathRect.isEmpty()) || rect ==
slowPathRect); |
| 324 #endif | 374 #endif |
| 325 } else { | 375 } else { |
| 326 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation
Container, rect); | 376 slowMapToVisibleRectInAncestorSpace(m_currentObject, *m_paintInvalidatio
nContainer, rect); |
| 327 } | 377 } |
| 328 | 378 |
| 329 if (m_paintInvalidationContainer.layer()->groupedMapping()) | 379 if (m_paintInvalidationContainer->layer()->groupedMapping()) |
| 330 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida
tionContainer, rect); | 380 PaintLayer::mapRectInPaintInvalidationContainerToBacking(*m_paintInvalid
ationContainer, rect); |
| 331 } | 381 } |
| 332 | 382 |
| 333 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutRect&
localClipRect) | 383 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutRect&
localClipRect) |
| 334 { | 384 { |
| 335 LayoutRect clipRect = localClipRect; | 385 LayoutRect clipRect = localClipRect; |
| 336 clipRect.move(m_paintOffset); | 386 clipRect.move(m_paintOffset); |
| 337 if (m_clipped) { | 387 if (m_clipped) { |
| 338 m_clipRect.intersect(clipRect); | 388 m_clipRect.intersect(clipRect); |
| 339 } else { | 389 } else { |
| 340 m_clipRect = clipRect; | 390 m_clipRect = clipRect; |
| 341 m_clipped = true; | 391 m_clipped = true; |
| 342 } | 392 } |
| 343 } | 393 } |
| 344 | 394 |
| 345 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec
t& layoutObject) const | 395 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec
t& layoutObject) const |
| 346 { | 396 { |
| 347 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP
aintingLayer()) | 397 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP
aintingLayer()) |
| 348 return *toLayoutBoxModelObject(layoutObject).layer(); | 398 return *toLayoutBoxModelObject(layoutObject).layer(); |
| 349 | 399 |
| 350 return m_enclosingSelfPaintingLayer; | 400 return m_enclosingSelfPaintingLayer; |
| 351 } | 401 } |
| 352 | 402 |
| 353 } // namespace blink | 403 } // namespace blink |
| OLD | NEW |