LayoutPoint RenderBoxModelObject::adjustedPositionRelativeToOffsetParent(const LayoutPoint& startPoint) const { // If the element is the HTML body element or doesn't have a parent // return 0 and stop this algorithm. if (isBody() || !parent()) return LayoutPoint(); LayoutPoint referencePoint = startPoint; referencePoint.move(parent()->columnOffset(referencePoint)); // If the offsetParent of the element is null, or is the HTML body element, // return the distance between the canvas origin and the left border edge // of the element and stop this algorithm. Element* element = offsetParent(); if (!element) return referencePoint; if (const RenderBoxModelObject* offsetParent = element->renderBoxModelObject()) { if (offsetParent->isBox() && !offsetParent->isBody()) referencePoint.move(-toRenderBox(offsetParent)->borderLeft(), -toRenderBox(offsetParent)->borderTop()); if (!isOutOfFlowPositioned() || flowThreadContainingBlock()) { if (isRelPositioned()) referencePoint.move(relativePositionOffset()); RenderObject* current; for (current = parent(); current != offsetParent && current->parent(); current = current->parent()) { // FIXME: What are we supposed to do inside SVG content? if (!isOutOfFlowPositioned()) { if (current->isBox() && !current->isTableRow()) referencePoint.moveBy(toRenderBox(current)->topLeftLocation()); referencePoint.move(current->parent()->columnOffset(referencePoint)); } } if (offsetParent->isBox() && offsetParent->isBody() && !offsetParent->isPositioned()) referencePoint.moveBy(toRenderBox(offsetParent)->topLeftLocation()); } } return referencePoint; }
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 RenderRegion::computeOverflowFromFlowThread() { ASSERT(isValid()); LayoutRect layoutRect; { // When getting the overflow from the flow thread we need to temporarly reset the current flow thread because // we're changing flows. CurrentRenderFlowThreadMaintainer flowThreadMaintainer(m_flowThread); layoutRect = layoutOverflowRectForBox(m_flowThread); } layoutRect.setLocation(contentBoxRect().location() + (layoutRect.location() - m_flowThreadPortionRect.location())); // FIXME: Correctly adjust the layout overflow for writing modes. addLayoutOverflow(layoutRect); RenderFlowThread* enclosingRenderFlowThread = flowThreadContainingBlock(); if (enclosingRenderFlowThread) enclosingRenderFlowThread->addRegionsLayoutOverflow(this, layoutRect); updateLayerTransform(); updateScrollInfoAfterLayout(); }