void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { bool hadTransform = hasTransform(); RenderObject::styleDidChange(diff, oldStyle); updateFromStyle(); LayerType type = layerTypeRequired(); if (type != NoLayer) { if (!layer() && layerCreationAllowedForSubtree()) { if (s_wasFloating && isFloating()) setChildNeedsLayout(); createLayer(type); if (parent() && !needsLayout() && containingBlock()) { // FIXME: This invalidation is overly broad. We should update to // do the correct invalidation at RenderStyle::diff time. crbug.com/349061 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) layer()->renderer()->setShouldDoFullPaintInvalidationAfterLayout(true); else layer()->repainter().setRepaintStatus(NeedsFullRepaint); // Hit in animations/interpolation/perspective-interpolation.html // FIXME: I suspect we can remove this assert disabler now. DisableCompositingQueryAsserts disabler; layer()->updateLayerPositionRecursive(); } } } else if (layer() && layer()->parent()) { setHasTransform(false); // Either a transform wasn't specified or the object doesn't support transforms, so just null out the bit. setHasReflection(false); layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer if (s_wasFloating && isFloating()) setChildNeedsLayout(); if (hadTransform) setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); } if (layer()) { // FIXME: Ideally we shouldn't need this setter but we can't easily infer an overflow-only layer // from the style. layer()->setLayerType(type); layer()->styleChanged(diff, oldStyle); } if (FrameView *frameView = view()->frameView()) { bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosition(); bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition(); if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { if (newStyleIsViewportConstained && layer()) frameView->addViewportConstrainedObject(this); else frameView->removeViewportConstrainedObject(this); } } }
void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { bool hadTransform = hasTransform(); bool hadLayer = hasLayer(); bool layerWasSelfPainting = hadLayer && layer()->isSelfPaintingLayer(); RenderObject::styleDidChange(diff, oldStyle); updateFromStyle(); LayerType type = layerTypeRequired(); if (type != NoLayer) { if (!layer() && layerCreationAllowedForSubtree()) { if (s_wasFloating && isFloating()) setChildNeedsLayout(); createLayer(type); if (parent() && !needsLayout()) { // FIXME: We should call a specialized version of this function. layer()->updateLayerPositionsAfterLayout(); } } } else if (layer() && layer()->parent()) { setHasTransform(false); // Either a transform wasn't specified or the object doesn't support transforms, so just null out the bit. setHasReflection(false); layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer if (s_wasFloating && isFloating()) setChildNeedsLayout(); if (hadTransform) setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); } if (layer()) { // FIXME: Ideally we shouldn't need this setter but we can't easily infer an overflow-only layer // from the style. layer()->setLayerType(type); layer()->styleChanged(diff, oldStyle); if (hadLayer && layer()->isSelfPaintingLayer() != layerWasSelfPainting) setChildNeedsLayout(); } if (FrameView *frameView = view()->frameView()) { bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosition(); bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition(); if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { if (newStyleIsViewportConstained && layer()) frameView->addViewportConstrainedObject(this); else frameView->removeViewportConstrainedObject(this); } } }
void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { bool hadTransform = hasTransform(); bool hadLayer = hasLayer(); bool layerWasSelfPainting = hadLayer && layer()->isSelfPaintingLayer(); RenderObject::styleDidChange(diff, oldStyle); updateFromStyle(); if (requiresLayer()) { if (!layer() && layerCreationAllowedForSubtree()) { if (s_wasFloating && isFloating()) setChildNeedsLayout(); createLayer(); if (parent() && !needsLayout() && containingBlock()) { layer()->repainter().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()) { setHasTransform(false); // Either a transform wasn't specified or the object doesn't support transforms, so just null out the bit. setHasReflection(false); layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer if (s_wasFloating && isFloating()) setChildNeedsLayout(); if (hadTransform) setNeedsLayoutAndPrefWidthsRecalc(); } if (layer()) { layer()->styleChanged(diff, oldStyle); if (hadLayer && layer()->isSelfPaintingLayer() != layerWasSelfPainting) setChildNeedsLayout(); } if (FrameView *frameView = view()->frameView()) { bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosition(); bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition(); if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) { if (newStyleIsViewportConstained && layer()) frameView->addViewportConstrainedObject(this); else frameView->removeViewportConstrainedObject(this); } } }
void RenderView::layout() { if (printing()) m_minPrefWidth = m_maxPrefWidth = width(); // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account. bool relayoutChildren = !printing() && (!m_frameView || width() != viewWidth() || height() != viewHeight()); if (relayoutChildren) { setChildNeedsLayout(true, false); for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { if (child->style()->height().isPercent() || child->style()->minHeight().isPercent() || child->style()->maxHeight().isPercent()) child->setChildNeedsLayout(true, false); } } ASSERT(!m_layoutState); LayoutState state; // FIXME: May be better to push a clip and avoid issuing offscreen repaints. state.m_clipped = false; m_layoutState = &state; if (needsLayout()) RenderBlock::layout(); // Reset overflow and then replace it with docWidth and docHeight. m_overflow.clear(); addLayoutOverflow(IntRect(0, 0, docWidth(), docHeight())); ASSERT(layoutDelta() == IntSize()); ASSERT(m_layoutStateDisableCount == 0); ASSERT(m_layoutState == &state); m_layoutState = 0; setNeedsLayout(false); }
void RenderMedia::layout() { IntSize oldSize = contentBoxRect().size(); RenderImage::layout(); RenderBox* controlsRenderer = m_controls->renderBox(); if (!controlsRenderer) return; IntSize newSize = contentBoxRect().size(); if (newSize == oldSize && !controlsRenderer->needsLayout()) return; // When calling layout() on a child node, a parent must either push a LayoutStateMaintainter, or // call view()->disableLayoutState(). Since using a LayoutStateMaintainer is slightly more efficient, // and this method will be called many times per second during playback, use a LayoutStateMaintainer: LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); controlsRenderer->setLocation(borderLeft() + paddingLeft(), borderTop() + paddingTop()); controlsRenderer->style()->setHeight(Length(newSize.height(), Fixed)); controlsRenderer->style()->setWidth(Length(newSize.width(), Fixed)); controlsRenderer->setNeedsLayout(true, false); controlsRenderer->layout(); setChildNeedsLayout(false); statePusher.pop(); }
void RenderSVGContainer::insertChildNode(RenderObject* child, RenderObject* beforeChild, bool) { if (!beforeChild) { appendChildNode(child); return; } ASSERT(!child->parent()); ASSERT(beforeChild->parent() == this); ASSERT(child->element()->isSVGElement()); if (beforeChild == m_firstChild) m_firstChild = child; RenderObject* prev = beforeChild->previousSibling(); child->setNextSibling(beforeChild); beforeChild->setPreviousSibling(child); if (prev) prev->setNextSibling(child); child->setPreviousSibling(prev); child->setParent(this); child->setNeedsLayoutAndPrefWidthsRecalc(); if (!normalChildNeedsLayout()) setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child. if (AXObjectCache::accessibilityEnabled()) document()->axObjectCache()->childrenChanged(this); }
void RenderView::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; if (!document().paginated()) setPageLogicalHeight(0); if (shouldUsePrintingLayout()) m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth(); // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account. bool relayoutChildren = !shouldUsePrintingLayout() && (width() != viewWidth() || height() != viewHeight()); if (relayoutChildren) { setChildNeedsLayout(MarkOnlyThis); for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { if (!child->isBox()) continue; RenderBox& box = toRenderBox(*child); if (box.hasRelativeLogicalHeight() || box.hasViewportPercentageLogicalHeight() || box.style()->logicalHeight().isPercent() || box.style()->logicalMinHeight().isPercent() || box.style()->logicalMaxHeight().isPercent() || box.style()->logicalHeight().isViewportPercentage() || box.style()->logicalMinHeight().isViewportPercentage() || box.style()->logicalMaxHeight().isViewportPercentage() #if ENABLE(SVG) || box.isSVGRoot() #endif ) box.setChildNeedsLayout(MarkOnlyThis); } } ASSERT(!m_layoutState); if (!needsLayout()) return; m_layoutState = std::make_unique<LayoutState>(); bool isSeamlessAncestorInFlowThread = initializeLayoutState(*m_layoutState); m_pageLogicalHeightChanged = false; if (checkTwoPassLayoutForAutoHeightRegions()) layoutContentInAutoLogicalHeightRegions(*m_layoutState); else layoutContent(*m_layoutState); layoutContentToComputeOverflowInRegions(*m_layoutState); #ifndef NDEBUG checkLayoutState(*m_layoutState); #endif m_layoutState = nullptr; clearNeedsLayout(); if (isSeamlessAncestorInFlowThread) flowThreadController().setCurrentRenderFlowThread(0); }
void RenderView::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; if (!document()->paginated()) setPageLogicalHeight(0); if (shouldUsePrintingLayout()) m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth(); // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account. bool relayoutChildren = !shouldUsePrintingLayout() && (!m_frameView || width() != viewWidth() || height() != viewHeight()); if (relayoutChildren) { setChildNeedsLayout(true, MarkOnlyThis); for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { if ((child->isBox() && toRenderBox(child)->hasRelativeLogicalHeight()) || child->style()->logicalHeight().isPercent() || child->style()->logicalMinHeight().isPercent() || child->style()->logicalMaxHeight().isPercent()) child->setChildNeedsLayout(true, MarkOnlyThis); } } ASSERT(!m_layoutState); if (!needsLayout()) return; LayoutState state; // FIXME: May be better to push a clip and avoid issuing offscreen repaints. state.m_clipped = false; state.m_pageLogicalHeight = m_pageLogicalHeight; state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged; state.m_isPaginated = state.m_pageLogicalHeight; m_pageLogicalHeightChanged = false; m_layoutState = &state; m_layoutPhase = RenderViewNormalLayout; bool needsTwoPassLayoutForAutoLogicalHeightRegions = hasRenderNamedFlowThreads() && flowThreadController()->hasAutoLogicalHeightRegions() && flowThreadController()->hasRenderNamedFlowThreadsNeedingLayout(); if (needsTwoPassLayoutForAutoLogicalHeightRegions) flowThreadController()->resetRegionsOverrideLogicalContentHeight(); layoutContent(state); if (needsTwoPassLayoutForAutoLogicalHeightRegions) { m_layoutPhase = ConstrainedFlowThreadsLayoutInAutoLogicalHeightRegions; flowThreadController()->markAutoLogicalHeightRegionsForLayout(); layoutContent(state); } #ifndef NDEBUG checkLayoutState(state); #endif m_layoutState = 0; setNeedsLayout(false); }
void RenderContainer::insertChildNode(RenderObject* child, RenderObject* beforeChild, bool fullInsert) { if (!beforeChild) { appendChildNode(child); return; } ASSERT(!child->parent()); while (beforeChild->parent() != this && beforeChild->parent()->isAnonymousBlock()) beforeChild = beforeChild->parent(); ASSERT(beforeChild->parent() == this); ASSERT(!isBlockFlow() || (!child->isTableSection() && !child->isTableRow() && !child->isTableCell())); if (beforeChild == m_firstChild) m_firstChild = child; RenderObject* prev = beforeChild->previousSibling(); child->setNextSibling(beforeChild); beforeChild->setPreviousSibling(child); if(prev) prev->setNextSibling(child); child->setPreviousSibling(prev); child->setParent(this); if (fullInsert) { // Keep our layer hierarchy updated. Optimize for the common case where we don't have any children // and don't have a layer attached to ourselves. RenderLayer* layer = 0; if (child->firstChild() || child->hasLayer()) { layer = enclosingLayer(); child->addLayers(layer, child); } // if the new child is visible but this object was not, tell the layer it has some visible content // that needs to be drawn and layer visibility optimization can't be used if (style()->visibility() != VISIBLE && child->style()->visibility() == VISIBLE && !child->hasLayer()) { if (!layer) layer = enclosingLayer(); if (layer) layer->setHasVisibleContent(true); } if (!child->isFloating() && childrenInline()) dirtyLinesFromChangedChild(child); } child->setNeedsLayoutAndPrefWidthsRecalc(); if (!normalChildNeedsLayout()) setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child. if (AXObjectCache::accessibilityEnabled()) document()->axObjectCache()->childrenChanged(this); }
void RenderView::layout() { if (!document()->paginated()) setPageHeight(0); m_absoluteOverflow.clear(); if (printing()) m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = width(); // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account. bool relayoutChildren = !printing() && (!m_frameView || width() != viewWidth() || height() != viewHeight()); if (relayoutChildren) { setChildNeedsLayout(true, false); for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { if (child->style()->logicalHeight().isPercent() || child->style()->logicalMinHeight().isPercent() || child->style()->logicalMaxHeight().isPercent()) child->setChildNeedsLayout(true, false); } } ASSERT(!m_layoutState); LayoutState state; // FIXME: May be better to push a clip and avoid issuing offscreen repaints. state.m_clipped = false; state.m_pageHeight = m_pageHeight; state.m_pageHeightChanged = m_pageHeightChanged; m_pageHeightChanged = false; m_layoutState = &state; if (needsLayout()) RenderBlock::layout(); #if ENABLE(VIEWPORT_REFLOW) calcReflowWidth(); #endif // Reset overflow and then replace it with docWidth and docHeight. m_overflow.clear(); int leftOverflow = docLeft(); addLayoutOverflow(IntRect(leftOverflow, 0, docWidth(leftOverflow), docHeight())); ASSERT(layoutDelta() == IntSize()); ASSERT(m_layoutStateDisableCount == 0); ASSERT(m_layoutState == &state); m_layoutState = 0; setNeedsLayout(false); }
void RenderContainer::appendChildNode(RenderObject* newChild, bool fullAppend) { ASSERT(newChild->parent() == 0); ASSERT(!isBlockFlow() || (!newChild->isTableSection() && !newChild->isTableRow() && !newChild->isTableCell())); newChild->setParent(this); RenderObject* lChild = m_lastChild; if (lChild) { newChild->setPreviousSibling(lChild); lChild->setNextSibling(newChild); } else m_firstChild = newChild; m_lastChild = newChild; if (fullAppend) { // Keep our layer hierarchy updated. Optimize for the common case where we don't have any children // and don't have a layer attached to ourselves. RenderLayer* layer = 0; if (newChild->firstChild() || newChild->hasLayer()) { layer = enclosingLayer(); newChild->addLayers(layer, newChild); } // if the new child is visible but this object was not, tell the layer it has some visible content // that needs to be drawn and layer visibility optimization can't be used if (style()->visibility() != VISIBLE && newChild->style()->visibility() == VISIBLE && !newChild->hasLayer()) { if (!layer) layer = enclosingLayer(); if (layer) layer->setHasVisibleContent(true); } if (!newChild->isFloatingOrPositioned() && childrenInline()) dirtyLinesFromChangedChild(newChild); } newChild->setNeedsLayoutAndPrefWidthsRecalc(); // Goes up the containing block hierarchy. if (!normalChildNeedsLayout()) setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child. if (AXObjectCache::accessibilityEnabled()) document()->axObjectCache()->childrenChanged(this); }
void RenderView::layout() { layoutCounter.startCounting(); if (printing()) m_minPrefWidth = m_maxPrefWidth = m_width; // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account. bool relayoutChildren = !printing() && (!m_frameView || m_width != viewWidth() || m_height != viewHeight()); if (relayoutChildren) { setChildNeedsLayout(true, false); for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { if (child->style()->height().isPercent() || child->style()->minHeight().isPercent() || child->style()->maxHeight().isPercent()) child->setChildNeedsLayout(true, false); } } ASSERT(!m_layoutState); LayoutState state; IntRect viewRectangle = viewRect(); // An empty rect is not valid viewRect. state.m_clipped = !viewRectangle.isEmpty(); if (state.m_clipped) { state.m_clipRect = IntRect(IntPoint(0, 0), viewRectangle.size()); state.m_offset = IntSize(viewRectangle.x(), viewRectangle.y()); } m_layoutState = &state; if (needsLayout()) RenderBlock::layout(); // Ensure that docWidth() >= width() and docHeight() >= height(). setOverflowWidth(m_width); setOverflowHeight(m_height); setOverflowWidth(docWidth()); setOverflowHeight(docHeight()); ASSERT(m_layoutStateDisableCount == 0); ASSERT(m_layoutState == &state); m_layoutState = 0; setNeedsLayout(false); layoutCounter.stopCounting(); }
void RenderView::layout() { if (!document()->paginated()) setPageLogicalHeight(0); if (shouldUsePrintingLayout()) m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = logicalWidth(); // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account. bool relayoutChildren = !shouldUsePrintingLayout() && (!m_frameView || width() != viewWidth() || height() != viewHeight()); if (relayoutChildren) { setChildNeedsLayout(true, MarkOnlyThis); for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { if ((child->isBox() && toRenderBox(child)->hasRelativeLogicalHeight()) || child->style()->logicalHeight().isPercent() || child->style()->logicalMinHeight().isPercent() || child->style()->logicalMaxHeight().isPercent()) child->setChildNeedsLayout(true, MarkOnlyThis); } } ASSERT(!m_layoutState); LayoutState state; // FIXME: May be better to push a clip and avoid issuing offscreen repaints. state.m_clipped = false; state.m_pageLogicalHeight = m_pageLogicalHeight; state.m_pageLogicalHeightChanged = m_pageLogicalHeightChanged; state.m_isPaginated = state.m_pageLogicalHeight; m_pageLogicalHeightChanged = false; m_layoutState = &state; if (needsLayout()) { RenderBlock::layout(); if (hasRenderNamedFlowThreads()) flowThreadController()->layoutRenderNamedFlowThreads(); } ASSERT(layoutDelta() == LayoutSize()); ASSERT(m_layoutStateDisableCount == 0); ASSERT(m_layoutState == &state); m_layoutState = 0; setNeedsLayout(false); }
bool RenderMultiColumnBlock::relayoutForPagination(bool, LayoutUnit, LayoutStateMaintainer& statePusher) { if (m_inBalancingPass || !requiresBalancing()) return false; m_inBalancingPass = true; // Prevent re-entering this method (and recursion into layout). bool needsRelayout; bool neededRelayout = false; bool firstPass = true; do { // Column heights may change here because of balancing. We may have to do multiple layout // passes, depending on how the contents is fitted to the changed column heights. In most // cases, laying out again twice or even just once will suffice. Sometimes we need more // passes than that, though, but the number of retries should not exceed the number of // columns, unless we have a bug. needsRelayout = false; for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBox->nextSiblingBox()) if (childBox != m_flowThread && childBox->isRenderMultiColumnSet()) { RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(childBox); if (multicolSet->calculateBalancedHeight(firstPass)) { multicolSet->setChildNeedsLayout(MarkOnlyThis); needsRelayout = true; } } if (needsRelayout) { // Layout again. Column balancing resulted in a new height. neededRelayout = true; m_flowThread->setChildNeedsLayout(MarkOnlyThis); setChildNeedsLayout(MarkOnlyThis); if (firstPass) statePusher.pop(); layoutBlock(false); } firstPass = false; } while (needsRelayout); m_inBalancingPass = false; return neededRelayout; }
void RenderMultiColumnSet::resetColumnHeight() { // Nuke previously stored minimum column height. Contents may have changed for all we know. m_minimumColumnHeight = 0; m_maxColumnHeight = calculateMaxColumnHeight(); LayoutUnit oldColumnHeight = pageLogicalHeight(); if (multiColumnFlowThread()->requiresBalancing()) m_columnHeight = 0; else setAndConstrainColumnHeight(heightAdjustedForSetOffset(multiColumnFlowThread()->columnHeightAvailable())); if (pageLogicalHeight() != oldColumnHeight) setChildNeedsLayout(MarkOnlyThis); // Content runs are only needed in the initial layout pass, in order to find an initial column // height, and should have been deleted afterwards. We're about to rebuild the content runs, so // the list needs to be empty. ASSERT(m_contentRuns.isEmpty()); }
void RenderMedia::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; LayoutSize oldSize = contentBoxRect().size(); RenderImage::layout(); RenderBox* controlsRenderer = toRenderBox(m_children.firstChild()); if (!controlsRenderer) return; bool controlsNeedLayout = controlsRenderer->needsLayout(); // If the region chain has changed we also need to relayout the controls to update the region box info. // FIXME: We can do better once we compute region box info for RenderReplaced, not only for RenderBlock. const RenderFlowThread* flowThread = flowThreadContainingBlock(); if (flowThread && !controlsNeedLayout) { if (flowThread->pageLogicalSizeChanged()) controlsNeedLayout = true; } LayoutSize newSize = contentBoxRect().size(); if (newSize == oldSize && !controlsNeedLayout) return; // When calling layout() on a child node, a parent must either push a LayoutStateMaintainter, or // instantiate LayoutStateDisabler. Since using a LayoutStateMaintainer is slightly more efficient, // and this method will be called many times per second during playback, use a LayoutStateMaintainer: LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); controlsRenderer->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop())); controlsRenderer->style()->setHeight(Length(newSize.height(), Fixed)); controlsRenderer->style()->setWidth(Length(newSize.width(), Fixed)); controlsRenderer->setNeedsLayout(true, MarkOnlyThis); controlsRenderer->layout(); setChildNeedsLayout(false); statePusher.pop(); }
void RenderSVGContainer::appendChildNode(RenderObject* newChild, bool) { ASSERT(!newChild->parent()); ASSERT(newChild->element()->isSVGElement()); newChild->setParent(this); RenderObject* lChild = m_lastChild; if (lChild) { newChild->setPreviousSibling(lChild); lChild->setNextSibling(newChild); } else m_firstChild = newChild; m_lastChild = newChild; newChild->setNeedsLayoutAndPrefWidthsRecalc(); // Goes up the containing block hierarchy. if (!normalChildNeedsLayout()) setChildNeedsLayout(true); // We may supply the static position for an absolute positioned child. if (AXObjectCache::accessibilityEnabled()) document()->axObjectCache()->childrenChanged(this); }
bool LayoutMultiColumnFlowThread::recalculateColumnHeights() { // All column sets that needed layout have now been laid out, so we can finally validate them. validateColumnSets(); if (!m_needsColumnHeightsRecalculation) return false; // Column heights may change here because of balancing. We may have to do multiple layout // passes, depending on how the contents is fitted to the changed column heights. In most // cases, laying out again twice or even just once will suffice. Sometimes we need more // passes than that, though, but the number of retries should not exceed the number of // columns, unless we have a bug. bool needsRelayout = false; for (LayoutMultiColumnSet* multicolSet = firstMultiColumnSet(); multicolSet; multicolSet = multicolSet->nextSiblingMultiColumnSet()) needsRelayout |= multicolSet->recalculateColumnHeight(); if (needsRelayout) setChildNeedsLayout(MarkOnlyThis); m_inBalancingPass = needsRelayout; return needsRelayout; }
void RenderView::layout() { if (m_printingMode) m_minWidth = m_width; // FIXME: This is all just a terrible workaround for bugs in layout when the view height changes. // Find a better way to detect view height changes. We're guessing that if we don't need layout that the reason // we were called is because of a FrameView bounds change. if (!needsLayout()) { setChildNeedsLayout(true, false); setMinMaxKnown(false); for (RenderObject *c = firstChild(); c; c = c->nextSibling()) c->setChildNeedsLayout(true, false); } if (recalcMinMax()) recalcMinMaxWidths(); RenderBlock::layout(); int docw = docWidth(); int doch = docHeight(); if (!m_printingMode) { setWidth(m_frameView->visibleWidth()); setHeight(m_frameView->visibleHeight()); } // ### we could maybe do the call below better and only pass true if the docsize changed. layoutPositionedObjects( true ); layer()->setHeight(max(doch, m_height)); layer()->setWidth(max(docw, m_width)); setNeedsLayout(false); }
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 }