void RenderSVGRoot::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; ASSERT(needsLayout()); m_resourcesNeedingToInvalidateClients.clear(); // Arbitrary affine transforms are incompatible with LayoutState. LayoutStateDisabler layoutStateDisabler(view()); bool needsLayout = selfNeedsLayout(); LayoutRepainter repainter(*this, checkForRepaintDuringLayout() && needsLayout); LayoutSize oldSize = size(); updateLogicalWidth(); updateLogicalHeight(); buildLocalToBorderBoxTransform(); m_isLayoutSizeChanged = needsLayout || (svgSVGElement().hasRelativeLengths() && oldSize != size()); SVGRenderSupport::layoutChildren(*this, needsLayout || SVGRenderSupport::filtersForceContainerLayout(*this)); if (!m_resourcesNeedingToInvalidateClients.isEmpty()) { // Invalidate resource clients, which may mark some nodes for layout. for (auto& resource : m_resourcesNeedingToInvalidateClients) { resource->removeAllClientsFromCache(); SVGResourcesCache::clientStyleChanged(*resource, StyleDifferenceLayout, resource->style()); } m_isLayoutSizeChanged = false; SVGRenderSupport::layoutChildren(*this, false); } // At this point LayoutRepainter already grabbed the old bounds, // recalculate them now so repaintAfterLayout() uses the new bounds. if (m_needsBoundariesOrTransformUpdate) { updateCachedBoundaries(); m_needsBoundariesOrTransformUpdate = false; } clearOverflow(); if (!shouldApplyViewportClip()) { FloatRect contentRepaintRect = repaintRectInLocalCoordinates(); contentRepaintRect = m_localToBorderBoxTransform.mapRect(contentRepaintRect); addVisualOverflow(enclosingLayoutRect(contentRepaintRect)); } updateLayerTransform(); m_hasBoxDecorations = isDocumentElementRenderer() ? hasVisibleBoxDecorationStyle() : hasVisibleBoxDecorations(); invalidateBackgroundObscurationStatus(); repainter.repaintAfterLayout(); clearNeedsLayout(); }
void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { RenderElement::styleDidChange(diff, oldStyle); updateFromStyle(); if (requiresLayer()) { if (!layer() && layerCreationAllowedForSubtree()) { if (s_wasFloating && isFloating()) setChildNeedsLayout(); createLayer(); if (parent() && !needsLayout() && containingBlock()) { layer()->setRepaintStatus(NeedsFullRepaint); // There is only one layer to update, it is not worth using |cachedOffset| since // we are not sure the value will be used. layer()->updateLayerPositions(0); } } } else if (layer() && layer()->parent()) { #if ENABLE(CSS_COMPOSITING) if (oldStyle->hasBlendMode()) layer()->parent()->dirtyAncestorChainHasBlendingDescendants(); #endif setHasTransformRelatedProperty(false); // All transform-related propeties force layers, so we know we don't have one or the object doesn't support them. setHasReflection(false); // Repaint the about to be destroyed self-painting layer when style change also triggers repaint. if (layer()->isSelfPaintingLayer() && layer()->repaintStatus() == NeedsFullRepaint) repaintUsingContainer(containerForRepaint(), layer()->repaintRect()); layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer if (s_wasFloating && isFloating()) setChildNeedsLayout(); if (s_hadTransform) setNeedsLayoutAndPrefWidthsRecalc(); } if (layer()) { layer()->styleChanged(diff, oldStyle); if (s_hadLayer && layer()->isSelfPaintingLayer() != s_layerWasSelfPainting) setChildNeedsLayout(); } bool newStyleIsViewportConstrained = style().hasViewportConstrainedPosition(); bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition(); if (newStyleIsViewportConstrained != oldStyleIsViewportConstrained) { if (newStyleIsViewportConstrained && layer()) view().frameView().addViewportConstrainedObject(this); else view().frameView().removeViewportConstrainedObject(this); } #if ENABLE(CSS_SCROLL_SNAP) const RenderStyle& newStyle = style(); if (oldStyle && scrollSnapContainerRequiresUpdateForStyleUpdate(*oldStyle, newStyle)) { if (RenderLayer* renderLayer = layer()) { renderLayer->updateSnapOffsets(); renderLayer->updateScrollSnapState(); } else if (isBody() || isDocumentElementRenderer()) { FrameView& frameView = view().frameView(); frameView.updateSnapOffsets(); frameView.updateScrollSnapState(); frameView.updateScrollingCoordinatorScrollSnapProperties(); } } if (oldStyle && oldStyle->scrollSnapCoordinates() != newStyle.scrollSnapCoordinates()) { const RenderBox* scrollSnapBox = enclosingBox().findEnclosingScrollableContainer(); if (scrollSnapBox && scrollSnapBox->layer()) { const RenderStyle& style = scrollSnapBox->style(); if (style.scrollSnapType() != ScrollSnapType::None) { scrollSnapBox->layer()->updateSnapOffsets(); scrollSnapBox->layer()->updateScrollSnapState(); if (scrollSnapBox->isBody() || scrollSnapBox->isDocumentElementRenderer()) scrollSnapBox->view().frameView().updateScrollingCoordinatorScrollSnapProperties(); } } } #endif }