Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp

Issue 2692853016: Change PaintLayer::m_layoutObject to a reference. (Closed)
Patch Set: Added TODO Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp b/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp
index d7d7cdb1ae7e1d8fa87a293786686914c7cb5244..a9aaa381dcaa511e54ed9ac049395b7972004827 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp
@@ -36,8 +36,8 @@ static inline bool shouldSuppressPaintingLayer(const PaintLayer& layer) {
// invalidate all painted output via a call to
// LayoutView::invalidatePaintForViewAndCompositedLayers(). We also avoid
// caching subsequences in this mode; see shouldCreateSubsequence().
- if (layer.layoutObject()->document().didLayoutWithPendingStylesheets() &&
- !layer.isRootLayer() && !layer.layoutObject()->isDocumentElement())
+ if (layer.layoutObject().document().didLayoutWithPendingStylesheets() &&
+ !layer.isRootLayer() && !layer.layoutObject().isDocumentElement())
return true;
return false;
@@ -56,17 +56,17 @@ void PaintLayerPainter::paint(GraphicsContext& context,
static ShouldRespectOverflowClipType shouldRespectOverflowClip(
PaintLayerFlags paintFlags,
- const LayoutObject* layoutObject) {
+ const LayoutObject& layoutObject) {
return (paintFlags & PaintLayerPaintingOverflowContents ||
(paintFlags & PaintLayerPaintingChildClippingMaskPhase &&
- layoutObject->hasClipPath()))
+ layoutObject.hasClipPath()))
? IgnoreOverflowClip
: RespectOverflowClip;
}
bool PaintLayerPainter::paintedOutputInvisible(
const PaintLayerPaintingInfo& paintingInfo) {
- const LayoutObject& layoutObject = *m_paintLayer.layoutObject();
+ const LayoutObject& layoutObject = m_paintLayer.layoutObject();
if (layoutObject.hasBackdropFilter())
return false;
@@ -123,8 +123,8 @@ PaintResult PaintLayerPainter::paint(GraphicsContext& context,
if (shouldSuppressPaintingLayer(m_paintLayer))
return FullyPainted;
- if (m_paintLayer.layoutObject()->view()->frame() &&
- m_paintLayer.layoutObject()->view()->frame()->shouldThrottleRendering())
+ if (m_paintLayer.layoutObject().view()->frame() &&
+ m_paintLayer.layoutObject().view()->frame()->shouldThrottleRendering())
return FullyPainted;
// If this layer is totally invisible then there is nothing to paint.
@@ -184,7 +184,7 @@ static bool shouldCreateSubsequence(const PaintLayer& paintLayer,
// Create subsequence for only stacking contexts whose painting are atomic.
// SVG is also painted atomically.
if (!paintLayer.stackingNode()->isStackingContext() &&
- !paintLayer.layoutObject()->isSVGRoot())
+ !paintLayer.layoutObject().isSVGRoot())
return false;
// The layer doesn't have children. Subsequence caching is not worth because
@@ -192,14 +192,14 @@ static bool shouldCreateSubsequence(const PaintLayer& paintLayer,
// SVG is also painted atomically.
if (!PaintLayerStackingNodeIterator(*paintLayer.stackingNode(), AllChildren)
.next() &&
- !paintLayer.layoutObject()->isSVGRoot())
+ !paintLayer.layoutObject().isSVGRoot())
return false;
// When in FOUC-avoidance mode, don't cache any subsequences, to avoid having
// to invalidate all of them when leaving this mode. There is an early-out in
// BlockPainter::paintContents that may result in nothing getting painted in
// this mode, in addition to early-out logic in PaintLayerPainter.
- if (paintLayer.layoutObject()->document().didLayoutWithPendingStylesheets())
+ if (paintLayer.layoutObject().document().didLayoutWithPendingStylesheets())
return false;
return true;
@@ -269,18 +269,16 @@ PaintResult PaintLayerPainter::paintLayerContents(
Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties;
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
- m_paintLayer.layoutObject() &&
- m_paintLayer.layoutObject()->isLayoutView()) {
+ m_paintLayer.layoutObject().isLayoutView()) {
const auto* objectPaintProperties =
- m_paintLayer.layoutObject()->paintProperties();
+ m_paintLayer.layoutObject().paintProperties();
DCHECK(objectPaintProperties &&
objectPaintProperties->localBorderBoxProperties());
PaintChunkProperties properties(
context.getPaintController().currentPaintChunkProperties());
properties.propertyTreeState =
*objectPaintProperties->localBorderBoxProperties();
- properties.backfaceHidden =
- m_paintLayer.layoutObject()->hasHiddenBackface();
+ properties.backfaceHidden = m_paintLayer.layoutObject().hasHiddenBackface();
scopedPaintChunkProperties.emplace(context.getPaintController(),
m_paintLayer, properties);
}
@@ -308,16 +306,16 @@ PaintResult PaintLayerPainter::paintLayerContents(
bool shouldPaintSelfOutline =
isSelfPaintingLayer && !isPaintingOverlayScrollbars &&
(isPaintingCompositedDecoration || !isPaintingScrollingContent) &&
- m_paintLayer.layoutObject()->styleRef().hasOutline();
+ m_paintLayer.layoutObject().styleRef().hasOutline();
PaintResult result = FullyPainted;
if (paintFlags & PaintLayerPaintingRootBackgroundOnly &&
- !m_paintLayer.layoutObject()->isLayoutView())
+ !m_paintLayer.layoutObject().isLayoutView())
return result;
- if (m_paintLayer.layoutObject()->view()->frame() &&
- m_paintLayer.layoutObject()->view()->frame()->shouldThrottleRendering())
+ if (m_paintLayer.layoutObject().view()->frame() &&
+ m_paintLayer.layoutObject().view()->frame()->shouldThrottleRendering())
return result;
// Ensure our lists are up to date.
@@ -369,7 +367,7 @@ PaintResult PaintLayerPainter::paintLayerContents(
// composited-scrolling container. It must, however, still be applied to the
// mask layer, so that the compositor can properly mask the
// scrolling contents and scrollbars.
- if (m_paintLayer.layoutObject()->hasClipPath() &&
+ if (m_paintLayer.layoutObject().hasClipPath() &&
(!m_paintLayer.needsCompositedScrolling() ||
(paintFlags & (PaintLayerPaintingChildClippingMaskPhase |
PaintLayerPaintingAncestorClippingMaskPhase)))) {
@@ -385,8 +383,8 @@ PaintResult PaintLayerPainter::paintLayerContents(
else
referenceBox.moveBy(offsetFromRoot);
clipPathClipper.emplace(
- context, *m_paintLayer.layoutObject()->styleRef().clipPath(),
- *m_paintLayer.layoutObject(), FloatRect(referenceBox),
+ context, *m_paintLayer.layoutObject().styleRef().clipPath(),
+ m_paintLayer.layoutObject(), FloatRect(referenceBox),
FloatPoint(referenceBox.location()));
}
@@ -402,11 +400,11 @@ PaintResult PaintLayerPainter::paintLayerContents(
paintingInfo.rootLayer, paintingInfo.subPixelAccumulation,
paintingInfo.getGlobalPaintFlags()));
compositingRecorder.emplace(
- context, *m_paintLayer.layoutObject(),
+ context, m_paintLayer.layoutObject(),
WebCoreCompositeToSkiaComposite(
CompositeSourceOver,
- m_paintLayer.layoutObject()->style()->blendMode()),
- m_paintLayer.layoutObject()->opacity(), &compositingBounds);
+ m_paintLayer.layoutObject().style()->blendMode()),
+ m_paintLayer.layoutObject().opacity(), &compositingBounds);
}
PaintLayerPaintingInfo localPaintingInfo(paintingInfo);
@@ -500,18 +498,16 @@ PaintResult PaintLayerPainter::paintLayerContents(
// the LayoutView's paint properties will already have been applied at
// the top of this method, in scopedPaintChunkProperties.
DCHECK(!(RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
- m_paintLayer.layoutObject() &&
- m_paintLayer.layoutObject()->isLayoutView()));
+ m_paintLayer.layoutObject().isLayoutView()));
const auto* objectPaintProperties =
- m_paintLayer.layoutObject()->paintProperties();
+ m_paintLayer.layoutObject().paintProperties();
DCHECK(objectPaintProperties &&
objectPaintProperties->localBorderBoxProperties());
PaintChunkProperties properties(
context.getPaintController().currentPaintChunkProperties());
properties.propertyTreeState =
*objectPaintProperties->localBorderBoxProperties();
- properties.backfaceHidden =
- m_paintLayer.layoutObject()->hasHiddenBackface();
+ properties.backfaceHidden = m_paintLayer.layoutObject().hasHiddenBackface();
contentScopedPaintChunkProperties.emplace(context.getPaintController(),
m_paintLayer, properties);
}
@@ -576,7 +572,7 @@ PaintResult PaintLayerPainter::paintLayerContents(
bool shouldPaintMask =
(paintFlags & PaintLayerPaintingCompositingMaskPhase) &&
- shouldPaintContent && m_paintLayer.layoutObject()->hasMask() &&
+ shouldPaintContent && m_paintLayer.layoutObject().hasMask() &&
!selectionOnly;
bool shouldPaintClippingMask =
(paintFlags & (PaintLayerPaintingChildClippingMaskPhase |
@@ -640,10 +636,10 @@ bool PaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(
}
inline bool PaintLayerPainter::isFixedPositionObjectInPagedMedia() {
- LayoutObject* object = m_paintLayer.layoutObject();
- LayoutView* view = object->view();
- return object->styleRef().position() == EPosition::kFixed &&
- object->container() == view && view->pageLogicalHeight() &&
+ LayoutObject& object = m_paintLayer.layoutObject();
+ LayoutView* view = object.view();
+ return object.styleRef().position() == EPosition::kFixed &&
+ object.container() == view && view->pageLogicalHeight() &&
// TODO(crbug.com/619094): Figure out the correct behaviour for fixed
// position objects in paged media with vertical writing modes.
view->isHorizontalWritingMode();
@@ -655,7 +651,7 @@ void PaintLayerPainter::repeatFixedPositionObjectInPages(
PaintLayerFragments& layerFragments) {
DCHECK(isFixedPositionObjectInPagedMedia());
- LayoutView* view = m_paintLayer.layoutObject()->view();
+ LayoutView* view = m_paintLayer.layoutObject().view();
unsigned pages =
ceilf(view->documentRect().height() / view->pageLogicalHeight());
@@ -772,7 +768,7 @@ PaintResult PaintLayerPainter::paintLayerWithTransform(
if (clipRectForFragment.isEmpty())
continue;
if (needsToClip(paintingInfo, clipRectForFragment)) {
- clipRecorder.emplace(context, *parentLayer->layoutObject(),
+ clipRecorder.emplace(context, parentLayer->layoutObject(),
DisplayItem::kClipLayerParent, clipRectForFragment,
paintingInfo.rootLayer, fragment.paginationOffset,
paintFlags);
@@ -808,7 +804,7 @@ PaintResult PaintLayerPainter::paintFragmentByApplyingTransform(
// matrix with the origin baked in.
FloatPoint3D transformOrigin;
Transform3DRecorder transform3DRecorder(
- context, *m_paintLayer.layoutObject(),
+ context, m_paintLayer.layoutObject(),
DisplayItem::kTransform3DElementTransform, transform, transformOrigin);
// Now do a paint with the root layer shifted to be us.
@@ -848,7 +844,7 @@ PaintResult PaintLayerPainter::paintChildren(
IntSize scrollOffsetAccumulationForChildren =
paintingInfo.scrollOffsetAccumulation;
- if (m_paintLayer.layoutObject()->hasOverflowClip())
+ if (m_paintLayer.layoutObject().hasOverflowClip())
scrollOffsetAccumulationForChildren +=
m_paintLayer.layoutBox()->scrolledContentOffset();
@@ -868,7 +864,7 @@ PaintResult PaintLayerPainter::paintChildren(
// to m_paintLayer.
for (PaintLayer* parentLayer = child->layer()->parent();
parentLayer != &m_paintLayer; parentLayer = parentLayer->parent()) {
- if (parentLayer->layoutObject()->hasOverflowClip())
+ if (parentLayer->layoutObject().hasOverflowClip())
childPaintingInfo.scrollOffsetAccumulation +=
parentLayer->layoutBox()->scrolledContentOffset();
}
@@ -910,7 +906,7 @@ void PaintLayerPainter::paintOverflowControlsForFragments(
Optional<LayerClipRecorder> clipRecorder;
if (needsToClip(localPaintingInfo, fragment.backgroundRect)) {
- clipRecorder.emplace(context, *m_paintLayer.layoutObject(),
+ clipRecorder.emplace(context, m_paintLayer.layoutObject(),
DisplayItem::kClipLayerOverflowControls,
fragment.backgroundRect, localPaintingInfo.rootLayer,
fragment.paginationOffset, paintFlags);
@@ -920,7 +916,7 @@ void PaintLayerPainter::paintOverflowControlsForFragments(
if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
!localPaintingInfo.scrollOffsetAccumulation.isZero()) {
cullRect.move(localPaintingInfo.scrollOffsetAccumulation);
- scrollRecorder.emplace(context, *m_paintLayer.layoutObject(),
+ scrollRecorder.emplace(context, m_paintLayer.layoutObject(),
DisplayItem::kScrollOverflowControls,
localPaintingInfo.scrollOffsetAccumulation);
}
@@ -965,7 +961,7 @@ void PaintLayerPainter::paintFragmentWithPhase(
// TODO(schenney): Nested border-radius clips are not applied to composited
// children, probably due to an incorrect clipRoot.
// https://bugs.chromium.org/p/chromium/issues/detail?id=672561
- clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType,
+ clipRecorder.emplace(context, m_paintLayer.layoutObject(), clipType,
clipRect, paintingInfo.rootLayer,
fragment.paginationOffset, paintFlags, clippingRule);
}
@@ -984,10 +980,10 @@ void PaintLayerPainter::paintFragmentWithPhase(
LayoutPoint paintOffset = -m_paintLayer.layoutBoxLocation();
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
const auto* objectPaintProperties =
- m_paintLayer.layoutObject()->paintProperties();
+ m_paintLayer.layoutObject().paintProperties();
DCHECK(objectPaintProperties &&
objectPaintProperties->localBorderBoxProperties());
- paintOffset += m_paintLayer.layoutObject()->paintOffset();
+ paintOffset += m_paintLayer.layoutObject().paintOffset();
newCullRect.move(paintingInfo.scrollOffsetAccumulation);
} else {
paintOffset += toSize(fragment.layerBounds.location());
@@ -1001,15 +997,15 @@ void PaintLayerPainter::paintFragmentWithPhase(
paintOffset += paintingInfo.scrollOffsetAccumulation;
newCullRect.move(paintingInfo.scrollOffsetAccumulation);
- scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase,
+ scrollRecorder.emplace(context, m_paintLayer.layoutObject(), phase,
paintingInfo.scrollOffsetAccumulation);
}
}
PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase,
paintingInfo.getGlobalPaintFlags(), paintFlags,
- paintingInfo.rootLayer->layoutObject());
+ &paintingInfo.rootLayer->layoutObject());
- m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
+ m_paintLayer.layoutObject().paint(paintInfo, paintOffset);
}
void PaintLayerPainter::paintBackgroundForFragments(
@@ -1045,11 +1041,10 @@ void PaintLayerPainter::paintForegroundForFragments(
Optional<LayerClipRecorder> clipRecorder;
if (shouldClip &&
needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) {
- clipRecorder.emplace(context, *m_paintLayer.layoutObject(),
- DisplayItem::kClipLayerForeground,
- layerFragments[0].foregroundRect,
- localPaintingInfo.rootLayer,
- layerFragments[0].paginationOffset, paintFlags);
+ clipRecorder.emplace(
+ context, m_paintLayer.layoutObject(), DisplayItem::kClipLayerForeground,
+ layerFragments[0].foregroundRect, localPaintingInfo.rootLayer,
+ layerFragments[0].paginationOffset, paintFlags);
clipState = HasClipped;
}
@@ -1161,7 +1156,7 @@ void PaintLayerPainter::paintMaskForFragments(
Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties;
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
const auto* objectPaintProperties =
- m_paintLayer.layoutObject()->paintProperties();
+ m_paintLayer.layoutObject().paintProperties();
DCHECK(objectPaintProperties && objectPaintProperties->mask());
PaintChunkProperties properties(
context.getPaintController().currentPaintChunkProperties());
@@ -1208,7 +1203,7 @@ void PaintLayerPainter::paintOverlayScrollbars(
void PaintLayerPainter::fillMaskingFragment(GraphicsContext& context,
const ClipRect& clipRect) {
- const LayoutObject& layoutObject = *m_paintLayer.layoutObject();
+ const LayoutObject& layoutObject = m_paintLayer.layoutObject();
if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(
context, layoutObject, PaintPhaseClippingMask))
return;

Powered by Google App Engine
This is Rietveld 408576698