| 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" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 context.paintingLayer->setNeedsPaintPhaseDescendantBlockBackgrounds(); | 159 context.paintingLayer->setNeedsPaintPhaseDescendantBlockBackgrounds(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 if (object.isTable()) { | 162 if (object.isTable()) { |
| 163 const LayoutTable& table = toLayoutTable(object); | 163 const LayoutTable& table = toLayoutTable(object); |
| 164 if (table.collapseBorders() && !table.collapsedBorders().isEmpty()) | 164 if (table.collapseBorders() && !table.collapsedBorders().isEmpty()) |
| 165 context.paintingLayer->setNeedsPaintPhaseDescendantBlockBackgrounds(
); | 165 context.paintingLayer->setNeedsPaintPhaseDescendantBlockBackgrounds(
); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 namespace { |
| 170 |
| 171 // This is temporary to workaround paint invalidation issues in non-rootLayerScr
olls mode. |
| 172 // It undos FrameView's content clip and scroll for paint invalidation of frame |
| 173 // scroll controls and the LayoutView to which the content clip and scroll don't
apply. |
| 174 class ScopedUndoFrameViewContentClipAndScroll { |
| 175 public: |
| 176 ScopedUndoFrameViewContentClipAndScroll(const FrameView& frameView, PaintInv
alidatorContext& context) |
| 177 : m_treeBuilderContext(const_cast<PaintPropertyTreeBuilderContext&>(cont
ext.treeBuilderContext)) |
| 178 , m_savedContext(m_treeBuilderContext.current) |
| 179 { |
| 180 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 181 |
| 182 if (frameView.contentClip() == m_savedContext.clip) |
| 183 m_treeBuilderContext.current.clip = m_savedContext.clip->parent(); |
| 184 if (frameView.scroll() == m_savedContext.scroll) |
| 185 m_treeBuilderContext.current.scroll = m_savedContext.scroll->parent(
); |
| 186 if (frameView.scrollTranslation() == m_savedContext.transform) |
| 187 m_treeBuilderContext.current.transform = m_savedContext.transform->p
arent(); |
| 188 } |
| 189 |
| 190 ~ScopedUndoFrameViewContentClipAndScroll() |
| 191 { |
| 192 m_treeBuilderContext.current = m_savedContext; |
| 193 } |
| 194 |
| 195 private: |
| 196 PaintPropertyTreeBuilderContext& m_treeBuilderContext; |
| 197 PaintPropertyTreeBuilderContext::ContainingBlockContext m_savedContext; |
| 198 }; |
| 199 |
| 200 } // namespace |
| 201 |
| 169 void PaintInvalidator::updateContext(const LayoutObject& object, PaintInvalidato
rContext& context) | 202 void PaintInvalidator::updateContext(const LayoutObject& object, PaintInvalidato
rContext& context) |
| 170 { | 203 { |
| 204 Optional<ScopedUndoFrameViewContentClipAndScroll> undoFrameViewContentClipAn
dScroll; |
| 205 |
| 171 if (object.isPaintInvalidationContainer()) { | 206 if (object.isPaintInvalidationContainer()) { |
| 172 context.paintInvalidationContainer = toLayoutBoxModelObject(&object); | 207 context.paintInvalidationContainer = toLayoutBoxModelObject(&object); |
| 173 if (object.styleRef().isStackingContext()) | 208 if (object.styleRef().isStackingContext()) |
| 174 context.paintInvalidationContainerForStackedContents = toLayoutBoxMo
delObject(&object); | 209 context.paintInvalidationContainerForStackedContents = toLayoutBoxMo
delObject(&object); |
| 175 } else if (object.isLayoutView()) { | 210 } else if (object.isLayoutView()) { |
| 176 // paintInvalidationContainerForStackedContents is only for stacked desc
endants in its own frame, | 211 // paintInvalidationContainerForStackedContents is only for stacked desc
endants in its own frame, |
| 177 // because it doesn't establish stacking context for stacked contents in
sub-frames. | 212 // because it doesn't establish stacking context for stacked contents in
sub-frames. |
| 178 // Contents stacked in the root stacking context in this frame should us
e this frame's paintInvalidationContainer. | 213 // Contents stacked in the root stacking context in this frame should us
e this frame's paintInvalidationContainer. |
| 179 context.paintInvalidationContainerForStackedContents = context.paintInva
lidationContainer; | 214 context.paintInvalidationContainerForStackedContents = context.paintInva
lidationContainer; |
| 215 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 216 undoFrameViewContentClipAndScroll.emplace(*toLayoutView(object).fram
eView(), context); |
| 180 } else if (object.styleRef().isStacked() | 217 } else if (object.styleRef().isStacked() |
| 181 // This is to exclude some objects (e.g. LayoutText) inheriting stacked
style from parent but aren't actually stacked. | 218 // This is to exclude some objects (e.g. LayoutText) inheriting stacked
style from parent but aren't actually stacked. |
| 182 && object.hasLayer() | 219 && object.hasLayer() |
| 183 && context.paintInvalidationContainer != context.paintInvalidationContai
nerForStackedContents) { | 220 && context.paintInvalidationContainer != context.paintInvalidationContai
nerForStackedContents) { |
| 184 // The current object is stacked, so we should use m_paintInvalidationCo
ntainerForStackedContents as its | 221 // The current object is stacked, so we should use m_paintInvalidationCo
ntainerForStackedContents as its |
| 185 // paint invalidation container on which the current object is painted. | 222 // paint invalidation container on which the current object is painted. |
| 186 context.paintInvalidationContainer = context.paintInvalidationContainerF
orStackedContents; | 223 context.paintInvalidationContainer = context.paintInvalidationContainerF
orStackedContents; |
| 187 if (context.forcedSubtreeInvalidationFlags & PaintInvalidatorContext::Fo
rcedSubtreeFullInvalidationForStackedContents) | 224 if (context.forcedSubtreeInvalidationFlags & PaintInvalidatorContext::Fo
rcedSubtreeFullInvalidationForStackedContents) |
| 188 context.forcedSubtreeInvalidationFlags |= PaintInvalidatorContext::F
orcedSubtreeFullInvalidation; | 225 context.forcedSubtreeInvalidationFlags |= PaintInvalidatorContext::F
orcedSubtreeFullInvalidation; |
| 189 } | 226 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 265 |
| 229 void PaintInvalidator::invalidatePaintIfNeeded(FrameView& frameView, PaintInvali
datorContext& context) | 266 void PaintInvalidator::invalidatePaintIfNeeded(FrameView& frameView, PaintInvali
datorContext& context) |
| 230 { | 267 { |
| 231 LayoutView* layoutView = frameView.layoutView(); | 268 LayoutView* layoutView = frameView.layoutView(); |
| 232 CHECK(layoutView); | 269 CHECK(layoutView); |
| 233 | 270 |
| 234 context.paintInvalidationContainer = context.paintInvalidationContainerForSt
ackedContents = &layoutView->containerForPaintInvalidation(); | 271 context.paintInvalidationContainer = context.paintInvalidationContainerForSt
ackedContents = &layoutView->containerForPaintInvalidation(); |
| 235 context.paintingLayer = layoutView->layer(); | 272 context.paintingLayer = layoutView->layer(); |
| 236 | 273 |
| 237 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 274 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 238 // Undo content clip and scroll before invalidating FrameView scrollbars
. | 275 ScopedUndoFrameViewContentClipAndScroll undo(frameView, context); |
| 239 PaintPropertyTreeBuilderContext& treeBuilderContext = const_cast<PaintPr
opertyTreeBuilderContext&>(context.treeBuilderContext); | |
| 240 PaintPropertyTreeBuilderContext::ContainingBlockContext savedCurrent = t
reeBuilderContext.current; | |
| 241 if (frameView.contentClip() == savedCurrent.clip) | |
| 242 treeBuilderContext.current.clip = savedCurrent.clip->parent(); | |
| 243 if (frameView.scroll() == savedCurrent.scroll) | |
| 244 treeBuilderContext.current.scroll = savedCurrent.scroll->parent(); | |
| 245 if (frameView.scrollTranslation() == savedCurrent.transform) | |
| 246 treeBuilderContext.current.transform = savedCurrent.transform->paren
t(); | |
| 247 frameView.invalidatePaintOfScrollControlsIfNeeded(context); | 276 frameView.invalidatePaintOfScrollControlsIfNeeded(context); |
| 248 treeBuilderContext.current = savedCurrent; | |
| 249 } | 277 } |
| 250 | 278 |
| 251 if (frameView.frame().selection().isCaretBoundsDirty()) | 279 if (frameView.frame().selection().isCaretBoundsDirty()) |
| 252 frameView.frame().selection().invalidateCaretRect(); | 280 frameView.frame().selection().invalidateCaretRect(); |
| 253 | 281 |
| 254 // Temporary callback for crbug.com/487345,402044 | 282 // Temporary callback for crbug.com/487345,402044 |
| 255 // TODO(ojan): Make this more general to be used by PositionObserver | 283 // TODO(ojan): Make this more general to be used by PositionObserver |
| 256 // and rAF throttling. | 284 // and rAF throttling. |
| 257 IntRect visibleRect = frameView.rootFrameToContents(frameView.computeVisible
Area()); | 285 IntRect visibleRect = frameView.rootFrameToContents(frameView.computeVisible
Area()); |
| 258 layoutView->sendMediaPositionChangeNotifications(visibleRect); | 286 layoutView->sendMediaPositionChangeNotifications(visibleRect); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 object.getMutableForPainting().clearPaintInvalidationFlags(); | 352 object.getMutableForPainting().clearPaintInvalidationFlags(); |
| 325 } | 353 } |
| 326 | 354 |
| 327 void PaintInvalidator::processPendingDelayedPaintInvalidations() | 355 void PaintInvalidator::processPendingDelayedPaintInvalidations() |
| 328 { | 356 { |
| 329 for (auto target : m_pendingDelayedPaintInvalidations) | 357 for (auto target : m_pendingDelayedPaintInvalidations) |
| 330 target->getMutableForPainting().setShouldDoFullPaintInvalidation(PaintIn
validationDelayedFull); | 358 target->getMutableForPainting().setShouldDoFullPaintInvalidation(PaintIn
validationDelayedFull); |
| 331 } | 359 } |
| 332 | 360 |
| 333 } // namespace blink | 361 } // namespace blink |
| OLD | NEW |