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" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 // (see LayoutBoxModelObject.h) but we need them to be in physical | 28 // (see LayoutBoxModelObject.h) but we need them to be in physical |
| 29 // coordinates. | 29 // coordinates. |
| 30 FloatRect rect = localRect; | 30 FloatRect rect = localRect; |
| 31 if (object.isBox()) | 31 if (object.isBox()) |
| 32 toLayoutBox(object).flipForWritingMode(rect); | 32 toLayoutBox(object).flipForWritingMode(rect); |
| 33 | 33 |
| 34 LayoutRect result; | 34 LayoutRect result; |
| 35 if (object == context.paintInvalidationContainer) { | 35 if (object == context.paintInvalidationContainer) { |
| 36 result = LayoutRect(rect); | 36 result = LayoutRect(rect); |
| 37 } else { | 37 } else { |
| 38 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); | |
| 39 | |
| 40 bool success = false; | |
| 41 PropertyTreeState currentTreeState(context.treeBuilderContext.current.tr ansform, context.treeBuilderContext.current.clip, context.treeBuilderContext.cur rentEffect); | 38 PropertyTreeState currentTreeState(context.treeBuilderContext.current.tr ansform, context.treeBuilderContext.current.clip, context.treeBuilderContext.cur rentEffect); |
| 42 PropertyTreeState containerTreeState; | 39 PropertyTreeState containerTreeState; |
| 43 context.paintInvalidationContainer->objectPaintProperties()->getContents Properties(containerTreeState); | 40 const ObjectPaintProperties* containerPaintProperties = context.paintInv alidationContainer->objectPaintProperties(); |
| 41 containerPaintProperties->getContentsProperties(containerTreeState); | |
| 42 | |
| 43 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); | |
| 44 bool success = false; | |
| 44 result = LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace(rec t, currentTreeState, containerTreeState, success)); | 45 result = LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace(rec t, currentTreeState, containerTreeState, success)); |
| 45 DCHECK(success); | 46 DCHECK(success); |
| 47 result.moveBy(-containerPaintProperties->localBorderBoxProperties()->pai ntOffset); | |
| 46 } | 48 } |
| 47 | 49 |
| 48 if (context.paintInvalidationContainer->layer()->groupedMapping()) | 50 if (context.paintInvalidationContainer->layer()->groupedMapping()) |
| 49 PaintLayer::mapRectInPaintInvalidationContainerToBacking(*context.paintI nvalidationContainer, result); | 51 PaintLayer::mapRectInPaintInvalidationContainerToBacking(*context.paintI nvalidationContainer, result); |
| 50 return result; | 52 return result; |
| 51 } | 53 } |
| 52 | 54 |
| 53 void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking(const Layou tObject& object, LayoutRect& rect) const | 55 void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking(const Layou tObject& object, LayoutRect& rect) const |
| 54 { | 56 { |
| 55 GeometryMapper geometryMapper; | 57 GeometryMapper geometryMapper; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 if (frameView.frame().selection().isCaretBoundsDirty()) | 190 if (frameView.frame().selection().isCaretBoundsDirty()) |
| 189 frameView.frame().selection().invalidateCaretRect(); | 191 frameView.frame().selection().invalidateCaretRect(); |
| 190 | 192 |
| 191 // Temporary callback for crbug.com/487345,402044 | 193 // Temporary callback for crbug.com/487345,402044 |
| 192 // TODO(ojan): Make this more general to be used by PositionObserver | 194 // TODO(ojan): Make this more general to be used by PositionObserver |
| 193 // and rAF throttling. | 195 // and rAF throttling. |
| 194 IntRect visibleRect = frameView.rootFrameToContents(frameView.computeVisible Area()); | 196 IntRect visibleRect = frameView.rootFrameToContents(frameView.computeVisible Area()); |
| 195 layoutView->sendMediaPositionChangeNotifications(visibleRect); | 197 layoutView->sendMediaPositionChangeNotifications(visibleRect); |
| 196 } | 198 } |
| 197 | 199 |
| 200 static bool hasPercentageTransform(const ComputedStyle& style) | |
| 201 { | |
| 202 if (TransformOperation* translate = style.translate()) { | |
| 203 if (translate->dependsOnBoxSize()) | |
| 204 return true; | |
| 205 } | |
| 206 return style.transform().dependsOnBoxSize() | |
| 207 || (style.transformOriginX() != Length(50, Percent) && style.transformOr iginX().isPercentOrCalc()) | |
| 208 || (style.transformOriginY() != Length(50, Percent) && style.transformOr iginY().isPercentOrCalc()); | |
| 209 } | |
| 210 | |
|
Xianzhu
2016/09/13 17:42:33
This and the changes below are copied from LayoutB
| |
| 198 void PaintInvalidator::invalidatePaintIfNeeded(const LayoutObject& object, Paint InvalidatorContext& context) | 211 void PaintInvalidator::invalidatePaintIfNeeded(const LayoutObject& object, Paint InvalidatorContext& context) |
| 199 { | 212 { |
| 200 object.getMutableForPainting().ensureIsReadyForPaintInvalidation(); | 213 object.getMutableForPainting().ensureIsReadyForPaintInvalidation(); |
| 201 | 214 |
| 202 if (!context.forcedSubtreeInvalidationFlags && !object.shouldCheckForPaintIn validationRegardlessOfPaintInvalidationState()) | 215 if (!context.forcedSubtreeInvalidationFlags && !object.shouldCheckForPaintIn validationRegardlessOfPaintInvalidationState()) |
| 203 return; | 216 return; |
| 204 | 217 |
| 205 updatePaintingLayer(object, context); | 218 updatePaintingLayer(object, context); |
| 206 | 219 |
| 207 if (object.document().printing()) | 220 if (object.document().printing()) |
| 208 return; // Don't invalidate paints if we're printing. | 221 return; // Don't invalidate paints if we're printing. |
| 209 | 222 |
| 210 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "PaintInvalida tor::invalidatePaintIfNeeded()", "object", object.debugName().ascii()); | 223 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "PaintInvalida tor::invalidatePaintIfNeeded()", "object", object.debugName().ascii()); |
| 211 | 224 |
| 212 updateContext(object, context); | 225 updateContext(object, context); |
| 213 | 226 |
| 214 if (!object.shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationStat e() && context.forcedSubtreeInvalidationFlags == PaintInvalidatorContext::Forced SubtreeInvalidationRectUpdate) { | 227 if (!object.shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationStat e() && context.forcedSubtreeInvalidationFlags == PaintInvalidatorContext::Forced SubtreeInvalidationRectUpdate) { |
| 215 // We are done updating the paint invalidation rect. No other paint inva lidation work to do for this object. | 228 // We are done updating the paint invalidation rect. No other paint inva lidation work to do for this object. |
| 216 return; | 229 return; |
| 217 } | 230 } |
| 218 | 231 |
| 219 switch (object.invalidatePaintIfNeeded(context)) { | 232 PaintInvalidationReason reason = object.invalidatePaintIfNeeded(context); |
| 233 switch (reason) { | |
| 220 case PaintInvalidationDelayedFull: | 234 case PaintInvalidationDelayedFull: |
| 221 m_pendingDelayedPaintInvalidations.append(&object); | 235 m_pendingDelayedPaintInvalidations.append(&object); |
| 222 break; | 236 break; |
| 223 case PaintInvalidationSubtree: | 237 case PaintInvalidationSubtree: |
| 224 context.forcedSubtreeInvalidationFlags |= (PaintInvalidatorContext::Forc edSubtreeFullInvalidation | PaintInvalidatorContext::ForcedSubtreeFullInvalidati onForStackedContents); | 238 context.forcedSubtreeInvalidationFlags |= (PaintInvalidatorContext::Forc edSubtreeFullInvalidation | PaintInvalidatorContext::ForcedSubtreeFullInvalidati onForStackedContents); |
| 225 break; | 239 break; |
| 226 case PaintInvalidationSVGResourceChange: | 240 case PaintInvalidationSVGResourceChange: |
| 227 context.forcedSubtreeInvalidationFlags |= PaintInvalidatorContext::Force dSubtreeInvalidationChecking; | 241 context.forcedSubtreeInvalidationFlags |= PaintInvalidatorContext::Force dSubtreeInvalidationChecking; |
| 228 break; | 242 break; |
| 229 default: | 243 default: |
| 230 break; | 244 break; |
| 231 } | 245 } |
| 232 | 246 |
| 233 if (context.oldLocation != context.newLocation) | 247 if (context.oldLocation != context.newLocation) |
| 234 context.forcedSubtreeInvalidationFlags |= PaintInvalidatorContext::Force dSubtreeInvalidationChecking; | 248 context.forcedSubtreeInvalidationFlags |= PaintInvalidatorContext::Force dSubtreeInvalidationChecking; |
| 235 | 249 |
| 250 // TODO(crbug.com/533277): This is a workaround for the bug. Remove when we detect paint offset change. | |
| 251 if (reason != PaintInvalidationNone && hasPercentageTransform(object.styleRe f())) | |
| 252 context.forcedSubtreeInvalidationFlags |= PaintInvalidatorContext::Force dSubtreeInvalidationChecking; | |
| 253 | |
| 254 // TODO(crbug.com/490725): This is a workaround for the bug, to force descen dant to update paint invalidation | |
| 255 // rects on clipping change. | |
| 256 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() | |
| 257 && context.oldBounds != context.newBounds | |
| 258 // Note that isLayoutView() below becomes unnecessary after the launch o f root layer scrolling. | |
| 259 && (object.hasOverflowClip() || object.isLayoutView()) | |
| 260 && !toLayoutBox(object).usesCompositedScrolling()) | |
| 261 context.forcedSubtreeInvalidationFlags |= PaintInvalidatorContext::Force dSubtreeInvalidationRectUpdate; | |
| 262 | |
| 236 object.getMutableForPainting().clearPaintInvalidationFlags(); | 263 object.getMutableForPainting().clearPaintInvalidationFlags(); |
| 237 } | 264 } |
| 238 | 265 |
| 239 void PaintInvalidator::processPendingDelayedPaintInvalidations() | 266 void PaintInvalidator::processPendingDelayedPaintInvalidations() |
| 240 { | 267 { |
| 241 for (auto target : m_pendingDelayedPaintInvalidations) | 268 for (auto target : m_pendingDelayedPaintInvalidations) |
| 242 target->getMutableForPainting().setShouldDoFullPaintInvalidation(PaintIn validationDelayedFull); | 269 target->getMutableForPainting().setShouldDoFullPaintInvalidation(PaintIn validationDelayedFull); |
| 243 } | 270 } |
| 244 | 271 |
| 245 } // namespace blink | 272 } // namespace blink |
| OLD | NEW |