void RenderDialog::layout() { LayoutRepainter repainter(*this, true); LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); RenderBlock::layout(); RenderStyle* styleToUse = style(); if (styleToUse->position() != AbsolutePosition || !styleToUse->top().isAuto() || !styleToUse->bottom().isAuto()) { statePusher.pop(); return; } // Adjust the dialog's position to be centered in or at the top of the viewport. // FIXME: Figure out what to do in vertical writing mode. FrameView* frameView = document()->view(); int scrollTop = frameView->scrollOffset().height(); FloatPoint absolutePoint(0, scrollTop); int visibleHeight = frameView->visibleContentRect(true).height(); if (height() < visibleHeight) absolutePoint.move(0, (visibleHeight - height()) / 2); FloatPoint localPoint = containingBlock()->absoluteToLocal(absolutePoint); LayoutUnit localTop = LayoutSize(localPoint.x(), localPoint.y()).height(); setY(localTop); statePusher.pop(); // FIXME: Since there is always a layer here, repainter shouldn't be necessary. But without it, the dialog is sometimes not painted (see bug 90670). repainter.repaintAfterLayout(); }
inline void RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, SubtreeLayoutScope& layoutScope) { LayoutUnit oldLeft = logicalLeft(); bool logicalWidthChanged = updateLogicalWidthAndColumnWidth(); relayoutChildren |= logicalWidthChanged; LayoutState state(*this, locationOffset(), logicalWidthChanged); LayoutUnit beforeEdge = borderBefore() + paddingBefore(); LayoutUnit afterEdge = borderAfter() + paddingAfter(); LayoutUnit previousHeight = logicalHeight(); setLogicalHeight(beforeEdge); m_paintInvalidationLogicalTop = 0; m_paintInvalidationLogicalBottom = 0; if (!firstChild() && !isAnonymousBlock()) setChildrenInline(true); if (childrenInline()) layoutInlineChildren(relayoutChildren, m_paintInvalidationLogicalTop, m_paintInvalidationLogicalBottom, afterEdge); else layoutBlockChildren(relayoutChildren, layoutScope, beforeEdge, afterEdge); LayoutUnit oldClientAfterEdge = clientLogicalBottom(); updateLogicalHeight(); if (previousHeight != logicalHeight()) relayoutChildren = true; layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). computeOverflow(oldClientAfterEdge); }
void RenderVTTCue::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; RenderBlockFlow::layout(); #if ENABLE(WEBVTT_REGIONS) // If WebVTT Regions are used, the regular WebVTT layout algorithm is no // longer necessary, since cues having the region parameter set do not have // any positioning parameters. Also, in this case, the regions themselves // have positioning information. if (!m_cue->regionId().isEmpty()) return; #endif LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode()); if (m_cue->cueType()== TextTrackCue::WebVTT) { if (toVTTCue(m_cue)->snapToLines()) repositionCueSnapToLinesSet(); else repositionCueSnapToLinesNotSet(); } else repositionGenericCue(); statePusher.pop(); }
void RenderGrid::layoutBlock(bool relayoutChildren, LayoutUnit) { ASSERT(needsLayout()); if (!relayoutChildren && simplifiedLayout()) return; // FIXME: Much of this method is boiler plate that matches RenderBox::layoutBlock and Render*FlexibleBox::layoutBlock. // It would be nice to refactor some of the duplicate code. LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); if (inRenderFlowThread()) { // Regions changing widths can force us to relayout our children. if (logicalWidthChangedInRegions()) relayoutChildren = true; } computeInitialRegionRangeForBlock(); LayoutSize previousSize = size(); setLogicalHeight(0); computeLogicalWidth(); m_overflow.clear(); layoutGridItems(); LayoutUnit oldClientAfterEdge = clientLogicalBottom(); computeLogicalHeight(); if (size() != previousSize) relayoutChildren = true; layoutPositionedObjects(relayoutChildren || isRoot()); computeRegionRangeForBlock(); computeOverflow(oldClientAfterEdge); statePusher.pop(); updateLayerTransform(); // Update our scroll information if we're overflow:auto/scroll/hidden now that we know if // we overflow or not. if (hasOverflowClip()) layer()->updateScrollInfoAfterLayout(); repainter.repaintAfterLayout(); setNeedsLayout(false); }
void LayoutVTTCue::layout() { LayoutBlockFlow::layout(); DCHECK(firstChild()); LayoutState state(*this, locationOffset()); // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings - step 13. if (!std::isnan(m_snapToLinesPosition)) SnapToLinesLayouter(*this, computeControlsRect()).layout(); else repositionCueSnapToLinesNotSet(); }
void RenderTextTrackCue::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; RenderBlock::layout(); LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); if (m_cue->cueType()== TextTrackCue::WebVTT) { if (m_cue->snapToLines()) repositionCueSnapToLinesSet(); else repositionCueSnapToLinesNotSet(); } else repositionGenericCue(); statePusher.pop(); }
void RenderVTTCue::layout() { LayoutRectRecorder recorder(*this); RenderBlockFlow::layout(); // If WebVTT Regions are used, the regular WebVTT layout algorithm is no // longer necessary, since cues having the region parameter set do not have // any positioning parameters. Also, in this case, the regions themselves // have positioning information. if (!m_cue->regionId().isEmpty()) return; LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); if (m_cue->snapToLines()) repositionCueSnapToLinesSet(); else repositionCueSnapToLinesNotSet(); statePusher.pop(); }
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 LayoutVTTCue::layout() { LayoutBlockFlow::layout(); // If WebVTT Regions are used, the regular WebVTT layout algorithm is no // longer necessary, since cues having the region parameter set do not have // any positioning parameters. Also, in this case, the regions themselves // have positioning information. if (!m_cue->regionId().isEmpty()) return; ASSERT(firstChild()); LayoutState state(*this, locationOffset()); // Determine the area covered by the media controls, if any. If the controls // are present, they are the next sibling of the text track container, which // is our parent. (LayoutMedia ensures that the media controls are laid out // before text tracks, so that the layout is up-to-date here.) ASSERT(parent()->node()->isTextTrackContainer()); IntRect controlsRect; if (LayoutObject* parentSibling = parent()->nextSibling()) { // Only a part of the media controls is used for overlap avoidance. MediaControls* controls = toMediaControls(parentSibling->node()); if (LayoutObject* controlsLayout = controls->layoutObjectForTextTrackLayout()) controlsRect = controlsLayout->absoluteBoundingBoxRect(); } // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings - step 13. if (m_cue->snapToLines()) { SnapToLinesLayouter(*this, controlsRect, m_cue->calculateComputedLinePosition()).layout(); adjustForTopAndBottomMarginBorderAndPadding(); } else { repositionCueSnapToLinesNotSet(); } }
LayoutSize RenderSVGRoot::parentOriginToBorderBox() const { return locationOffset(); }
void LayoutSVGText::layout() { ASSERT(needsLayout()); LayoutAnalyzer::Scope analyzer(*this); subtreeStyleDidChange(); bool updateCachedBoundariesInParents = false; if (m_needsTransformUpdate) { m_localTransform = toSVGTextElement(node())->calculateAnimatedLocalTransform(); m_needsTransformUpdate = false; updateCachedBoundariesInParents = true; } if (!everHadLayout()) { // When laying out initially, collect all layout attributes, build the character data map, // and propogate resulting SVGLayoutAttributes to all LayoutSVGInlineText children in the subtree. ASSERT(m_layoutAttributes.isEmpty()); collectLayoutAttributes(this, m_layoutAttributes); updateFontInAllDescendants(this); m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this); m_needsReordering = true; m_needsTextMetricsUpdate = false; m_needsPositioningValuesUpdate = false; updateCachedBoundariesInParents = true; } else if (m_needsPositioningValuesUpdate) { // When the x/y/dx/dy/rotate lists change, recompute the layout attributes, and eventually // update the on-screen font objects as well in all descendants. if (m_needsTextMetricsUpdate) { updateFontInAllDescendants(this); m_needsTextMetricsUpdate = false; } m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this); m_needsReordering = true; m_needsPositioningValuesUpdate = false; updateCachedBoundariesInParents = true; } else if (m_needsTextMetricsUpdate || SVGLayoutSupport::findTreeRootObject(this)->isLayoutSizeChanged()) { // If the root layout size changed (eg. window size changes) or the transform to the root // context has changed then recompute the on-screen font size. updateFontInAllDescendants(this, &m_layoutAttributesBuilder); ASSERT(!m_needsReordering); ASSERT(!m_needsPositioningValuesUpdate); m_needsTextMetricsUpdate = false; updateCachedBoundariesInParents = true; } checkLayoutAttributesConsistency(this, m_layoutAttributes); // Reduced version of LayoutBlock::layoutBlock(), which only takes care of SVG text. // All if branches that could cause early exit in LayoutBlocks layoutBlock() method are turned into assertions. ASSERT(!isInline()); ASSERT(!simplifiedLayout()); ASSERT(!scrollsOverflow()); ASSERT(!hasControlClip()); ASSERT(!positionedObjects()); ASSERT(!isAnonymousBlock()); if (!firstChild()) setChildrenInline(true); // FIXME: We need to find a way to only layout the child boxes, if needed. FloatRect oldBoundaries = objectBoundingBox(); ASSERT(childrenInline()); rebuildFloatsFromIntruding(); LayoutUnit beforeEdge = borderBefore() + paddingBefore(); LayoutUnit afterEdge = borderAfter() + paddingAfter() + scrollbarLogicalHeight(); setLogicalHeight(beforeEdge); LayoutState state(*this, locationOffset()); LayoutUnit paintInvalidationLogicalTop = 0; LayoutUnit paintInvalidationLogicalBottom = 0; layoutInlineChildren(true, paintInvalidationLogicalTop, paintInvalidationLogicalBottom, afterEdge); if (m_needsReordering) m_needsReordering = false; // If we don't have any line boxes, then make sure the frame rect is still cleared. if (!firstLineBox()) setFrameRect(LayoutRect()); m_overflow.clear(); addVisualEffectOverflow(); if (!updateCachedBoundariesInParents) updateCachedBoundariesInParents = oldBoundaries != objectBoundingBox(); // Invalidate all resources of this client if our layout changed. if (everHadLayout() && selfNeedsLayout()) SVGResourcesCache::clientLayoutChanged(this); // If our bounds changed, notify the parents. if (updateCachedBoundariesInParents) LayoutSVGBlock::setNeedsBoundariesUpdate(); clearNeedsLayout(); }