LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const { // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height if (hasReplacedLogicalHeight()) return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(MainOrPreferredSize, style().logicalHeight())); RenderBox* contentRenderer = embeddedContentBox(); // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height double intrinsicRatio = 0; FloatSize constrainedSize; computeAspectRatioInformationForRenderBox(contentRenderer, constrainedSize, intrinsicRatio); bool widthIsAuto = style().logicalWidth().isAuto(); bool hasIntrinsicHeight = constrainedSize.height() > 0; // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'. if (widthIsAuto && hasIntrinsicHeight) return computeReplacedLogicalHeightRespectingMinMaxHeight(constrainedSize.height()); // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is: // (used width) / (intrinsic ratio) if (intrinsicRatio) return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(round(availableLogicalWidth() / intrinsicRatio))); // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'. if (hasIntrinsicHeight) return computeReplacedLogicalHeightRespectingMinMaxHeight(constrainedSize.height()); // Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to the height // of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width. return computeReplacedLogicalHeightRespectingMinMaxHeight(intrinsicLogicalHeight()); }
LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const { // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height if (hasReplacedLogicalHeight()) return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight())); RenderBox* contentRenderer = embeddedContentBox(); // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height bool isPercentageIntrinsicSize = false; double intrinsicRatio = 0; FloatSize intrinsicSize; computeIntrinsicRatioInformationForRenderBox(contentRenderer, intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize); // FIXME: Remove unnecessary round/roundToInt calls from this method when layout is off ints: webkit.org/b/63656 bool widthIsAuto = style()->logicalWidth().isAuto(); bool hasIntrinsicHeight = !isPercentageIntrinsicSize && intrinsicSize.height() > 0; // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'. if (widthIsAuto && hasIntrinsicHeight) return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(intrinsicSize.height())); // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is: // (used width) / (intrinsic ratio) if (intrinsicRatio) return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(round(availableLogicalWidth() / intrinsicRatio))); // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'. if (hasIntrinsicHeight) return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(intrinsicSize.height())); // Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to the height // of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width. return computeReplacedLogicalHeightRespectingMinMaxHeight(intrinsicLogicalHeight()); }
LayoutUnit LayoutReplaced::computeReplacedLogicalHeight( LayoutUnit estimatedUsedWidth) const { // 10.5 Content height: the 'height' property: // http://www.w3.org/TR/CSS21/visudet.html#propdef-height if (hasReplacedLogicalHeight()) return computeReplacedLogicalHeightRespectingMinMaxHeight( computeReplacedLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight())); LayoutReplaced* contentLayoutObject = embeddedReplacedContent(); // 10.6.2 Inline, replaced elements: // http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height IntrinsicSizingInfo intrinsicSizingInfo; computeIntrinsicSizingInfoForReplacedContent(contentLayoutObject, intrinsicSizingInfo); FloatSize constrainedSize = constrainIntrinsicSizeToMinMax(intrinsicSizingInfo); bool widthIsAuto = style()->logicalWidth().isAuto(); // If 'height' and 'width' both have computed values of 'auto' and the element // also has an intrinsic height, then that intrinsic height is the used value // of 'height'. if (widthIsAuto && intrinsicSizingInfo.hasHeight) return computeReplacedLogicalHeightRespectingMinMaxHeight( LayoutUnit(constrainedSize.height())); // Otherwise, if 'height' has a computed value of 'auto', and the element has // an intrinsic ratio then the used value of 'height' is: // (used width) / (intrinsic ratio) if (!intrinsicSizingInfo.aspectRatio.isEmpty()) { LayoutUnit usedWidth = estimatedUsedWidth ? estimatedUsedWidth : availableLogicalWidth(); return computeReplacedLogicalHeightRespectingMinMaxHeight( resolveHeightForRatio(usedWidth, intrinsicSizingInfo.aspectRatio)); } // Otherwise, if 'height' has a computed value of 'auto', and the element has // an intrinsic height, then that intrinsic height is the used value of // 'height'. if (intrinsicSizingInfo.hasHeight) return computeReplacedLogicalHeightRespectingMinMaxHeight( LayoutUnit(constrainedSize.height())); // Otherwise, if 'height' has a computed value of 'auto', but none of the // conditions above are met, then the used value of 'height' must be set to // the height of the largest rectangle that has a 2:1 ratio, has a height not // greater than 150px, and has a width not greater than the device width. return computeReplacedLogicalHeightRespectingMinMaxHeight( intrinsicLogicalHeight()); }
void RenderReplaced::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; ASSERT(needsLayout()); LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); setHeight(minimumReplacedHeight()); updateLogicalWidth(); updateLogicalHeight(); // Now that we've calculated our preferred layout, we check to see // if we should further constrain sizing to the intrinsic aspect ratio. if (style().aspectRatioType() == AspectRatioFromIntrinsic && !m_intrinsicSize.isEmpty()) { float aspectRatio = m_intrinsicSize.aspectRatio(); LayoutSize frameSize = size(); float frameAspectRatio = frameSize.aspectRatio(); if (frameAspectRatio < aspectRatio) setHeight(computeReplacedLogicalHeightRespectingMinMaxHeight(frameSize.height() * frameAspectRatio / aspectRatio)); else if (frameAspectRatio > aspectRatio) setWidth(computeReplacedLogicalWidthRespectingMinMaxWidth(frameSize.width() * aspectRatio / frameAspectRatio, ComputePreferred)); } clearOverflow(); addVisualEffectOverflow(); updateLayerTransform(); invalidateBackgroundObscurationStatus(); repainter.repaintAfterLayout(); clearNeedsLayout(); }
int RenderReplaced::computeIntrinsicLogicalHeight(RenderBox* contentRenderer) const { if (m_hasIntrinsicSize) return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight()); ASSERT(contentRenderer); ASSERT(contentRenderer->style()); return contentRenderer->computeReplacedLogicalHeightRespectingMinMaxHeight(contentRenderer->computeReplacedLogicalHeightUsing(contentRenderer->style()->logicalHeight())); }