void LayoutReplaced::computeIntrinsicSizingInfoForReplacedContent( LayoutReplaced* contentLayoutObject, IntrinsicSizingInfo& intrinsicSizingInfo) const { if (contentLayoutObject) { contentLayoutObject->computeIntrinsicSizingInfo(intrinsicSizingInfo); // Handle zoom & vertical writing modes here, as the embedded document // doesn't know about them. intrinsicSizingInfo.size.scale(style()->effectiveZoom()); if (isLayoutImage()) intrinsicSizingInfo.size.scale( toLayoutImage(this)->imageDevicePixelRatio()); // Update our intrinsic size to match what the content layoutObject has // computed, so that when we constrain the size below, the correct intrinsic // size will be obtained for comparison against min and max widths. if (!intrinsicSizingInfo.aspectRatio.isEmpty() && !intrinsicSizingInfo.size.isEmpty()) m_intrinsicSize = LayoutSize(intrinsicSizingInfo.size); if (!isHorizontalWritingMode()) intrinsicSizingInfo.transpose(); } else { computeIntrinsicSizingInfo(intrinsicSizingInfo); if (!intrinsicSizingInfo.aspectRatio.isEmpty() && !intrinsicSizingInfo.size.isEmpty()) m_intrinsicSize = LayoutSize(isHorizontalWritingMode() ? intrinsicSizingInfo.size : intrinsicSizingInfo.size.transposedSize()); } }
void LayoutReplaced::computeAspectRatioInformationForLayoutBox(LayoutBox* contentLayoutObject, FloatSize& constrainedSize, double& intrinsicRatio) const { FloatSize intrinsicSize; if (contentLayoutObject) { contentLayoutObject->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio); // Handle zoom & vertical writing modes here, as the embedded document doesn't know about them. intrinsicSize.scale(style()->effectiveZoom()); if (isLayoutImage()) intrinsicSize.scale(toLayoutImage(this)->imageDevicePixelRatio()); // Update our intrinsic size to match what the content layoutObject has computed, so that when we // constrain the size below, the correct intrinsic size will be obtained for comparison against // min and max widths. if (intrinsicRatio && !intrinsicSize.isEmpty()) m_intrinsicSize = LayoutSize(intrinsicSize); if (!isHorizontalWritingMode()) { if (intrinsicRatio) intrinsicRatio = 1 / intrinsicRatio; intrinsicSize = intrinsicSize.transposedSize(); } } else { computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio); if (intrinsicRatio && !intrinsicSize.isEmpty()) m_intrinsicSize = LayoutSize(isHorizontalWritingMode() ? intrinsicSize : intrinsicSize.transposedSize()); } // Now constrain the intrinsic size along each axis according to minimum and maximum width/heights along the // opposite axis. So for example a maximum width that shrinks our width will result in the height we compute here // having to shrink in order to preserve the aspect ratio. Because we compute these values independently along // each axis, the final returned size may in fact not preserve the aspect ratio. // FIXME: In the long term, it might be better to just return this code more to the way it used to be before this // function was added, since all it has done is make the code more unclear. constrainedSize = intrinsicSize; if (intrinsicRatio && !intrinsicSize.isEmpty() && style()->logicalWidth().isAuto() && style()->logicalHeight().isAuto()) { // We can't multiply or divide by 'intrinsicRatio' here, it breaks tests, like fast/images/zoomed-img-size.html, which // can only be fixed once subpixel precision is available for things like intrinsicWidth/Height - which include zoom! constrainedSize.setWidth(LayoutBox::computeReplacedLogicalHeight() * intrinsicSize.width() / intrinsicSize.height()); constrainedSize.setHeight(LayoutBox::computeReplacedLogicalWidth() * intrinsicSize.height() / intrinsicSize.width()); } }