void RenderFrame::layout() { FrameView* view = static_cast<FrameView*>(widget()); RenderView* root = view ? view->frame()->contentRenderer() : 0; // Do not expand frames which has zero width or height if (!width() || !height() || !root) { updateWidgetPosition(); if (view) view->layout(); setNeedsLayout(false); return; } HTMLFrameElementBase* element = static_cast<HTMLFrameElementBase*>(node()); if (element->scrollingMode() == ScrollbarAlwaysOff && !root->isFrameSet()) { setNeedsLayout(false); return; } // Update the dimensions to get the correct width and height updateWidgetPosition(); if (root->preferredLogicalWidthsDirty()) root->computePreferredLogicalWidths(); // Expand the frame by setting frame height = content height setWidth(max(view->contentsWidth() + borderAndPaddingWidth(), width())); setHeight(max(view->contentsHeight() + borderAndPaddingHeight(), height())); // Update one more time updateWidgetPosition(); setNeedsLayout(false); }
void RenderSlider::computePreferredLogicalWidths() { m_minPreferredLogicalWidth = 0; m_maxPreferredLogicalWidth = 0; if (style()->width().isFixed() && style()->width().value() > 0) m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->width().value()); else computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth); if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) { m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value())); m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value())); } if (style()->maxWidth().isFixed()) { m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value())); m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value())); } LayoutUnit toAdd = borderAndPaddingWidth(); m_minPreferredLogicalWidth += toAdd; m_maxPreferredLogicalWidth += toAdd; clearPreferredLogicalWidthsDirty(); }
void RenderDataGrid::computePreferredLogicalWidths() { m_minPreferredLogicalWidth = 0; m_maxPreferredLogicalWidth = 0; if (style()->width().isFixed() && style()->width().value() > 0) m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeContentBoxLogicalWidth(style()->width().value()); else m_maxPreferredLogicalWidth = computeContentBoxLogicalWidth(cDefaultWidth); if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) { m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->minWidth().value())); m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->minWidth().value())); } else if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent())) m_minPreferredLogicalWidth = 0; else m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth; if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) { m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value())); } int toAdd = borderAndPaddingWidth(); m_minPreferredLogicalWidth += toAdd; m_maxPreferredLogicalWidth += toAdd; setPreferredLogicalWidthsDirty(false); }
void RenderSVGRoot::updateCachedBoundaries() { SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m_objectBoundingBoxValid, m_strokeBoundingBox, m_repaintBoundingBoxExcludingShadow); SVGRenderSupport::intersectRepaintRectWithResources(*this, m_repaintBoundingBoxExcludingShadow); m_repaintBoundingBoxExcludingShadow.inflate(borderAndPaddingWidth()); m_repaintBoundingBox = m_repaintBoundingBoxExcludingShadow; SVGRenderSupport::intersectRepaintRectWithShadows(this, m_repaintBoundingBox); }
void RenderSVGRoot::updateCachedBoundaries() { m_objectBoundingBox = FloatRect(); m_strokeBoundingBox = FloatRect(); m_repaintBoundingBox = FloatRect(); SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m_strokeBoundingBox, m_repaintBoundingBox); SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingBox); m_repaintBoundingBox.inflate(borderAndPaddingWidth()); }
int RenderTextControl::textBlockWidth() const { Element* innerText = innerTextElement(); ASSERT(innerText); LayoutUnit unitWidth = width() - borderAndPaddingWidth(); if (innerText->renderer()) unitWidth -= innerText->renderBox()->paddingLeft() + innerText->renderBox()->paddingRight(); return unitWidth; }
void RenderSlider::layout() { ASSERT(needsLayout()); SliderThumbElement* thumbElement = shadowSliderThumb(); RenderBox* thumb = thumbElement ? toRenderBox(thumbElement->renderer()) : 0; IntSize baseSize(borderAndPaddingWidth(), borderAndPaddingHeight()); if (thumb) { // Allow the theme to set the size of the thumb. if (thumb->style()->hasAppearance()) { // FIXME: This should pass the style, not the renderer, to the theme. theme()->adjustSliderThumbSize(thumb); } baseSize.expand(thumb->style()->width().calcMinValue(0), thumb->style()->height().calcMinValue(0)); } LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); IntSize oldSize = size(); setSize(baseSize); computeLogicalWidth(); computeLogicalHeight(); updateLayerTransform(); if (thumb) { if (oldSize != size()) thumb->setChildNeedsLayout(true, false); LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), style()->isFlippedBlocksWritingMode()); IntRect oldThumbRect = thumb->frameRect(); thumb->layoutIfNeeded(); IntRect rect = thumbRect(); thumb->setFrameRect(rect); if (thumb->checkForRepaintDuringLayout()) thumb->repaintDuringLayoutIfMoved(oldThumbRect); statePusher.pop(); addOverflowFromChild(thumb); } repainter.repaintAfterLayout(); setNeedsLayout(false); }
void RenderReplaced::computePreferredLogicalWidths() { ASSERT(preferredLogicalWidthsDirty()); LayoutUnit borderAndPadding = borderAndPaddingWidth(); m_maxPreferredLogicalWidth = computeReplacedLogicalWidth(false) + borderAndPadding; if (style()->maxWidth().isFixed()) m_maxPreferredLogicalWidth = min<LayoutUnit>(m_maxPreferredLogicalWidth, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : ZERO_LAYOUT_UNIT)); if (hasRelativeDimensions()) m_minPreferredLogicalWidth = 0; else m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth; setPreferredLogicalWidthsDirty(false); }
void RenderSVGRoot::computePreferredLogicalWidths() { ASSERT(preferredLogicalWidthsDirty()); int borderAndPadding = borderAndPaddingWidth(); int width = computeReplacedLogicalWidth(false) + borderAndPadding; if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) width = min(width, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0)); if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent())) { m_minPreferredLogicalWidth = 0; m_maxPreferredLogicalWidth = width; } else m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = width; setPreferredLogicalWidthsDirty(false); }
void RenderTextControl::computePreferredLogicalWidths() { ASSERT(preferredLogicalWidthsDirty()); m_minPreferredLogicalWidth = 0; m_maxPreferredLogicalWidth = 0; if (style()->width().isFixed() && style()->width().value() >= 0) m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->width().value()); else { // Use average character width. Matches IE. AtomicString family = style()->font().family().family(); m_maxPreferredLogicalWidth = preferredContentWidth(getAvgCharWidth(family)); if (RenderBox* innerTextRenderBox = innerTextElement()->renderBox()) m_maxPreferredLogicalWidth += innerTextRenderBox->paddingLeft() + innerTextRenderBox->paddingRight(); if (!style()->width().isPercent()) m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth; } if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) { m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value())); m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value())); } if (style()->maxWidth().isFixed()) { m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value())); m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value())); } LayoutUnit toAdd = borderAndPaddingWidth(); m_minPreferredLogicalWidth += toAdd; m_maxPreferredLogicalWidth += toAdd; setPreferredLogicalWidthsDirty(false); }
int RenderTextControl::textBlockWidth() const { Element* innerText = innerTextElement(); ASSERT(innerText); return width() - borderAndPaddingWidth() - innerText->renderBox()->paddingLeft() - innerText->renderBox()->paddingRight(); }