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; if (contentRenderer) contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize); else computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize); if (intrinsicRatio && !isHorizontalWritingMode()) intrinsicRatio = 1 / intrinsicRatio; bool widthIsAuto = style()->logicalWidth().isAuto(); bool hasIntrinsicHeight = m_hasIntrinsicSize || (!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) { if (m_hasIntrinsicSize) return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight()); return static_cast<LayoutUnit>(intrinsicSize.height() * style()->effectiveZoom()); } // 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 && !isPercentageIntrinsicSize) { // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656 return computeReplacedLogicalHeightRespectingMinMaxHeight(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) { if (m_hasIntrinsicSize) return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight()); return static_cast<LayoutUnit>(intrinsicSize.height() * style()->effectiveZoom()); } // 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(cDefaultHeight); }
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())); }
int RenderReplaced::computeReplacedLogicalHeight() const { int logicalHeight; if (lengthIsSpecified(style()->logicalHeight())) logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight()); else if (m_hasIntrinsicSize) logicalHeight = calcAspectRatioLogicalHeight(); else logicalHeight = intrinsicLogicalHeight(); int minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMinHeight()); int maxLogicalHeight = style()->logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight()); return max(minLogicalHeight, min(logicalHeight, maxLogicalHeight)); }