void RenderNamedFlowFragment::updateLogicalHeight() { RenderRegion::updateLogicalHeight(); if (!hasAutoLogicalHeight()) return; // We want to update the logical height based on the computed auto-height // only after the measure cotnent layout phase when all the // auto logical height regions have a computed auto-height. if (m_flowThread->inMeasureContentLayoutPhase()) return; // There may be regions with auto logical height that during the prerequisite layout phase // did not have the chance to layout flow thread content. Because of that, these regions do not // have a computedAutoHeight and they will not be able to fragment any flow // thread content. if (!hasComputedAutoHeight()) return; LayoutUnit newLogicalHeight = computedAutoHeight() + borderAndPaddingLogicalHeight(); ASSERT(newLogicalHeight < RenderFlowThread::maxLogicalHeight()); if (newLogicalHeight > logicalHeight()) { setLogicalHeight(newLogicalHeight); // Recalculate position of the render block after new logical height is set. // (needed in absolute positioning case with bottom alignment for example) RenderRegion::updateLogicalHeight(); } }
void RenderRegion::updateLogicalHeight() { RenderBlock::updateLogicalHeight(); if (!hasAutoLogicalHeight()) return; // We want to update the logical height based on the computed override logical // content height only if the view is in the layout phase // in which all the auto logical height regions have their override logical height set. if (!m_flowThread->inConstrainedLayoutPhase()) return; // There may be regions with auto logical height that during the prerequisite layout phase // did not have the chance to layout flow thread content. Because of that, these regions do not // have an overrideLogicalContentHeight computed and they will not be able to fragment any flow // thread content. if (!hasOverrideHeight()) return; LayoutUnit newLogicalHeight = overrideLogicalContentHeight() + borderAndPaddingLogicalHeight(); ASSERT(newLogicalHeight < LayoutUnit::max() / 2); if (newLogicalHeight > logicalHeight()) setLogicalHeight(newLogicalHeight); }
void RenderGrid::layoutGridItems() { Vector<GridTrack> columnTracks(maximumIndexInDirection(ForColumns)); Vector<GridTrack> rowTracks(maximumIndexInDirection(ForRows)); computedUsedBreadthOfGridTracks(ForColumns, columnTracks, rowTracks); ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, columnTracks)); computedUsedBreadthOfGridTracks(ForRows, columnTracks, rowTracks); ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, rowTracks)); for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { LayoutPoint childPosition = findChildLogicalPosition(child, columnTracks, rowTracks); size_t columnTrack = resolveGridPosition(child->style()->gridItemColumn()); size_t rowTrack = resolveGridPosition(child->style()->gridItemRow()); // Because the grid area cannot be styled, we don't need to adjust // the grid breadth to account for 'box-sizing'. LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOverrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogicalWidth() : LayoutUnit(); LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOverrideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogicalHeight() : LayoutUnit(); if (oldOverrideContainingBlockContentLogicalWidth != columnTracks[columnTrack].m_usedBreadth || oldOverrideContainingBlockContentLogicalHeight != rowTracks[rowTrack].m_usedBreadth) child->setNeedsLayout(true, MarkOnlyThis); child->setOverrideContainingBlockContentLogicalWidth(columnTracks[columnTrack].m_usedBreadth); child->setOverrideContainingBlockContentLogicalHeight(rowTracks[rowTrack].m_usedBreadth); // FIXME: Grid items should stretch to fill their cells. Once we // implement grid-{column,row}-align, we can also shrink to fit. For // now, just size as if we were a regular child. child->layoutIfNeeded(); // FIXME: Handle border & padding on the grid element. child->setLogicalLocation(childPosition); } for (size_t i = 0; i < rowTracks.size(); ++i) setLogicalHeight(logicalHeight() + rowTracks[i].m_usedBreadth); // FIXME: We should handle min / max logical height. setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); }
int RenderTextControl::textBlockLogicalHeight() const { return logicalHeight() - borderAndPaddingLogicalHeight(); }
int LayoutTextControl::textBlockLogicalHeight() const { return (logicalHeight() - borderAndPaddingLogicalHeight()).toInt(); }
void LayoutReplaced::computePositionedLogicalHeight( LogicalExtentComputedValues& computedValues) const { // The following is based off of the W3C Working Draft from April 11, 2006 of // CSS 2.1: Section 10.6.5 "Absolutely positioned, replaced elements" // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-height> // (block-style-comments in this function correspond to text from the spec and // the numbers correspond to numbers in spec) // We don't use containingBlock(), since we may be positioned by an enclosing // relpositioned inline. const LayoutBoxModelObject* containerBlock = toLayoutBoxModelObject(container()); const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPositioned(containerBlock); const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, false); // Variables to solve. Length marginBefore = style()->marginBefore(); Length marginAfter = style()->marginAfter(); LayoutUnit& marginBeforeAlias = computedValues.m_margins.m_before; LayoutUnit& marginAfterAlias = computedValues.m_margins.m_after; Length logicalTop = style()->logicalTop(); Length logicalBottom = style()->logicalBottom(); // --------------------------------------------------------------------------- // 1. The used value of 'height' is determined as for inline replaced // elements. // --------------------------------------------------------------------------- // NOTE: This value of height is final in that the min/max height calculations // are dealt with in computeReplacedHeight(). This means that the steps to // produce correct max/min in the non-replaced version, are not necessary. computedValues.m_extent = computeReplacedLogicalHeight() + borderAndPaddingLogicalHeight(); const LayoutUnit availableSpace = containerLogicalHeight - computedValues.m_extent; // --------------------------------------------------------------------------- // 2. If both 'top' and 'bottom' have the value 'auto', replace 'top' with the // element's static position. // --------------------------------------------------------------------------- // see FIXME 1 computeBlockStaticDistance(logicalTop, logicalBottom, this, containerBlock); // --------------------------------------------------------------------------- // 3. If 'bottom' is 'auto', replace any 'auto' on 'margin-top' or // 'margin-bottom' with '0'. // --------------------------------------------------------------------------- // FIXME: The spec. says that this step should only be taken when bottom is // auto, but if only top is auto, this makes step 4 impossible. if (logicalTop.isAuto() || logicalBottom.isAuto()) { if (marginBefore.isAuto()) marginBefore.setValue(Fixed, 0); if (marginAfter.isAuto()) marginAfter.setValue(Fixed, 0); } // --------------------------------------------------------------------------- // 4. If at this point both 'margin-top' and 'margin-bottom' are still 'auto', // solve the equation under the extra constraint that the two margins must // get equal values. // --------------------------------------------------------------------------- LayoutUnit logicalTopValue; LayoutUnit logicalBottomValue; if (marginBefore.isAuto() && marginAfter.isAuto()) { // 'top' and 'bottom' cannot be 'auto' due to step 2 and 3 combined. ASSERT(!(logicalTop.isAuto() || logicalBottom.isAuto())); logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); LayoutUnit difference = availableSpace - (logicalTopValue + logicalBottomValue); // NOTE: This may result in negative values. marginBeforeAlias = difference / 2; // split the difference marginAfterAlias = difference - marginBeforeAlias; // account for odd valued differences // ------------------------------------------------------------------------- // 5. If at this point there is only one 'auto' left, solve the equation // for that value. // ------------------------------------------------------------------------- } else if (logicalTop.isAuto()) { marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogicalWidth); marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalWidth); logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); // Solve for 'top' logicalTopValue = availableSpace - (logicalBottomValue + marginBeforeAlias + marginAfterAlias); } else if (logicalBottom.isAuto()) { marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogicalWidth); marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalWidth); logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); // Solve for 'bottom' // NOTE: It is not necessary to solve for 'bottom' because we don't ever // use the value. } else if (marginBefore.isAuto()) { marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalWidth); logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); // Solve for 'margin-top' marginBeforeAlias = availableSpace - (logicalTopValue + logicalBottomValue + marginAfterAlias); } else if (marginAfter.isAuto()) { marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogicalWidth); logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); logicalBottomValue = valueForLength(logicalBottom, containerLogicalHeight); // Solve for 'margin-bottom' marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValue + marginBeforeAlias); } else { // Nothing is 'auto', just calculate the values. marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogicalWidth); marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalWidth); logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); // NOTE: It is not necessary to solve for 'bottom' because we don't ever // use the value. } // --------------------------------------------------------------------------- // 6. If at this point the values are over-constrained, ignore the value for // 'bottom' and solve for that value. // --------------------------------------------------------------------------- // NOTE: It is not necessary to do this step because we don't end up using the // value of 'bottom' regardless of whether the values are over-constrained or // not. // Use computed values to calculate the vertical position. LayoutUnit logicalTopPos = logicalTopValue + marginBeforeAlias; computeLogicalTopPositionedOffset(logicalTopPos, this, computedValues.m_extent, containerBlock, containerLogicalHeight); computedValues.m_position = logicalTopPos; }