void RenderTextControl::computePreferredLogicalWidths()
{
    ASSERT(preferredLogicalWidthsDirty());

    m_minPreferredLogicalWidth = 0;
    m_maxPreferredLogicalWidth = 0;

    if (style()->logicalWidth().isFixed() && style()->logicalWidth().value() >= 0)
        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->logicalWidth().value());
    else
        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);

    if (style()->logicalMinWidth().isFixed() && style()->logicalMinWidth().value() > 0) {
        m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->logicalMinWidth().value()));
        m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->logicalMinWidth().value()));
    }

    if (style()->logicalMaxWidth().isFixed()) {
        m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->logicalMaxWidth().value()));
        m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->logicalMaxWidth().value()));
    }

    LayoutUnit toAdd = borderAndPaddingLogicalWidth();

    m_minPreferredLogicalWidth += toAdd;
    m_maxPreferredLogicalWidth += toAdd;

    setPreferredLogicalWidthsDirty(false);
}
Esempio n. 2
0
void RenderReplaced::computePreferredLogicalWidths()
{
    ASSERT(preferredLogicalWidthsDirty());

    // We cannot resolve any percent logical width here as the available logical
    // width may not be set on our containing block.
    if (style()->logicalWidth().isPercent())
        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
    else
        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplacedLogicalWidth(ComputePreferred);

    RenderStyle* styleToUse = style();
    if (styleToUse->logicalWidth().isPercent() || styleToUse->logicalMaxWidth().isPercent() || hasRelativeIntrinsicLogicalWidth())
        m_minPreferredLogicalWidth = 0;

    if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth().value() > 0) {
        m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
        m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMinWidth().value()));
    }
    
    if (styleToUse->logicalMaxWidth().isFixed()) {
        m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
        m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
    }

    LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth();
    m_minPreferredLogicalWidth += borderAndPadding;
    m_maxPreferredLogicalWidth += borderAndPadding;

    setPreferredLogicalWidthsDirty(false);
}
Esempio n. 3
0
void RenderView::computePreferredLogicalWidths()
{
    ASSERT(preferredLogicalWidthsDirty());

    RenderBlock::computePreferredLogicalWidths();

    m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth;
}
void LayoutScrollbarPart::computePreferredLogicalWidths()
{
    if (!preferredLogicalWidthsDirty())
        return;

    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0;

    clearPreferredLogicalWidthsDirty();
}
Esempio n. 5
0
void RenderScrollbarPart::computePreferredLogicalWidths()
{
    if (!preferredLogicalWidthsDirty())
        return;
    
    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0;

    setPreferredLogicalWidthsDirty(false);
}
void RenderMathMLRoot::layout()
{
    // Our computePreferredLogicalWidths() may change our logical width and then layout our children, which
    // RenderBlock::layout()'s relayoutChildren logic isn't expecting.
    if (preferredLogicalWidthsDirty())
        computePreferredLogicalWidths();
    
    RenderMathMLBlock::layout();
    
    RenderBoxModelObject* index = this->index();
    // If |index|, it should be a RenderBlock here, unless the user has overriden its { position: absolute }.
    if (index && index->isBox())
        toRenderBox(index)->setLogicalTop(m_indexTop);
}
void RenderMathMLPadded::computePreferredLogicalWidths()
{
    ASSERT(preferredLogicalWidthsDirty());

    // Determine the intrinsic width of the content.
    RenderMathMLRow::computePreferredLogicalWidths();

    // Only the width attribute should modify the width.
    // We parse it using the preferred width of the content as its default value.
    LayoutUnit width = m_maxPreferredLogicalWidth;
    resolveWidth(width);
    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = width;

    setPreferredLogicalWidthsDirty(false);
}
void RenderMathMLFraction::computePreferredLogicalWidths()
{
    ASSERT(preferredLogicalWidthsDirty());

    m_minPreferredLogicalWidth = 0;
    m_maxPreferredLogicalWidth = 0;

    if (isValid()) {
        LayoutUnit numeratorWidth = numerator().maxPreferredLogicalWidth();
        LayoutUnit denominatorWidth = denominator().maxPreferredLogicalWidth();
        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = std::max(numeratorWidth, denominatorWidth);
    }

    setPreferredLogicalWidthsDirty(false);
}
void RenderMathMLRoot::computePreferredLogicalWidths()
{
    ASSERT(preferredLogicalWidthsDirty() && needsLayout());
    
#ifndef NDEBUG
    // FIXME: Remove this once mathml stops modifying the render tree here.
    SetLayoutNeededForbiddenScope layoutForbiddenScope(this, false);
#endif
    
    computeChildrenPreferredLogicalHeights();
    
    int baseHeight = firstChild() ? roundToInt(preferredLogicalHeightAfterSizing(firstChild())) : style()->fontSize();
    
    int frontWidth = lroundf(gFrontWidthEms * style()->fontSize());
    
    // Base height above which the shape of the root changes
    float thresholdHeight = gThresholdBaseHeightEms * style()->fontSize();
    if (baseHeight > thresholdHeight && thresholdHeight) {
        float shift = min<float>((baseHeight - thresholdHeight) / thresholdHeight, 1.0f);
        m_overbarLeftPointShift = static_cast<int>(shift * gRadicalBottomPointXFront * frontWidth);
        m_intrinsicPaddingAfter = lroundf(gBigRootBottomPaddingEms * style()->fontSize());
    } else {
        m_overbarLeftPointShift = 0;
        m_intrinsicPaddingAfter = 0;
    }
    
    int rootPad = lroundf(gSpaceAboveEms * style()->fontSize());
    m_intrinsicPaddingBefore = rootPad;
    m_indexTop = 0;
    if (RenderBoxModelObject* index = this->index()) {
        m_intrinsicPaddingStart = roundToInt(index->maxPreferredLogicalWidth()) + m_overbarLeftPointShift;
        
        int indexHeight = roundToInt(preferredLogicalHeightAfterSizing(index));
        int partDipHeight = lroundf((1 - gRootRadicalDipLeftPointYPos) * baseHeight);
        int rootExtraTop = partDipHeight + indexHeight - (baseHeight + rootPad);
        if (rootExtraTop > 0)
            m_intrinsicPaddingBefore += rootExtraTop;
        else
            m_indexTop = - rootExtraTop;
    } else
        m_intrinsicPaddingStart = frontWidth;

    RenderMathMLBlock::computePreferredLogicalWidths();
    
    // Shrink our logical width to its probable value now without triggering unnecessary relayout of our children.
    ASSERT(needsLayout() && logicalWidth() >= maxPreferredLogicalWidth());
    setLogicalWidth(maxPreferredLogicalWidth());
}
Esempio n. 10
0
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);
}
Esempio n. 11
0
void LayoutReplaced::computePreferredLogicalWidths() {
    ASSERT(preferredLogicalWidthsDirty());

    // We cannot resolve some logical width here (i.e. percent, fill-available or
    // fit-content) as the available logical width may not be set on our
    // containing block.
    const Length& logicalWidth = style()->logicalWidth();
    if (logicalWidth.isPercentOrCalc() || logicalWidth.isFillAvailable() ||
            logicalWidth.isFitContent())
        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth,
                                      m_maxPreferredLogicalWidth);
    else
        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth =
                                         computeReplacedLogicalWidth(ComputePreferred);

    const ComputedStyle& styleToUse = styleRef();
    if (styleToUse.logicalWidth().isPercentOrCalc() ||
            styleToUse.logicalMaxWidth().isPercentOrCalc())
        m_minPreferredLogicalWidth = LayoutUnit();

    if (styleToUse.logicalMinWidth().isFixed() &&
            styleToUse.logicalMinWidth().value() > 0) {
        m_maxPreferredLogicalWidth = std::max(
                                         m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                             styleToUse.logicalMinWidth().value()));
        m_minPreferredLogicalWidth = std::max(
                                         m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                             styleToUse.logicalMinWidth().value()));
    }

    if (styleToUse.logicalMaxWidth().isFixed()) {
        m_maxPreferredLogicalWidth = std::min(
                                         m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                             styleToUse.logicalMaxWidth().value()));
        m_minPreferredLogicalWidth = std::min(
                                         m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                             styleToUse.logicalMaxWidth().value()));
    }

    LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth();
    m_minPreferredLogicalWidth += borderAndPadding;
    m_maxPreferredLogicalWidth += borderAndPadding;

    clearPreferredLogicalWidthsDirty();
}
Esempio n. 12
0
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);
}
Esempio n. 13
0
void LayoutTextControl::computePreferredLogicalWidths() {
    ASSERT(preferredLogicalWidthsDirty());

    m_minPreferredLogicalWidth = LayoutUnit();
    m_maxPreferredLogicalWidth = LayoutUnit();
    const ComputedStyle& styleToUse = styleRef();

    if (styleToUse.logicalWidth().isFixed() &&
            styleToUse.logicalWidth().value() >= 0)
        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth =
                                         adjustContentBoxLogicalWidthForBoxSizing(
                                             styleToUse.logicalWidth().value());
    else
        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth,
                                      m_maxPreferredLogicalWidth);

    if (styleToUse.logicalMinWidth().isFixed() &&
            styleToUse.logicalMinWidth().value() > 0) {
        m_maxPreferredLogicalWidth = std::max(
                                         m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                             styleToUse.logicalMinWidth().value()));
        m_minPreferredLogicalWidth = std::max(
                                         m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                             styleToUse.logicalMinWidth().value()));
    }

    if (styleToUse.logicalMaxWidth().isFixed()) {
        m_maxPreferredLogicalWidth = std::min(
                                         m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                             styleToUse.logicalMaxWidth().value()));
        m_minPreferredLogicalWidth = std::min(
                                         m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(
                                             styleToUse.logicalMaxWidth().value()));
    }

    LayoutUnit toAdd = borderAndPaddingLogicalWidth();

    m_minPreferredLogicalWidth += toAdd;
    m_maxPreferredLogicalWidth += toAdd;

    clearPreferredLogicalWidthsDirty();
}
Esempio n. 14
0
void LayoutListMarker::computePreferredLogicalWidths() {
  ASSERT(preferredLogicalWidthsDirty());
  updateContent();

  if (isImage()) {
    LayoutSize imageSize(imageBulletSize());
    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth =
        style()->isHorizontalWritingMode() ? imageSize.width()
                                           : imageSize.height();
    clearPreferredLogicalWidthsDirty();
    updateMargins();
    return;
  }

  const Font& font = style()->font();
  const SimpleFontData* fontData = font.primaryFont();
  DCHECK(fontData);
  if (!fontData)
    return;

  LayoutUnit logicalWidth;
  switch (getListStyleCategory()) {
    case ListStyleCategory::None:
      break;
    case ListStyleCategory::Symbol:
      logicalWidth =
          LayoutUnit((fontData->getFontMetrics().ascent() * 2 / 3 + 1) / 2 + 2);
      break;
    case ListStyleCategory::Language:
      logicalWidth = getWidthOfTextWithSuffix();
      break;
  }

  m_minPreferredLogicalWidth = logicalWidth;
  m_maxPreferredLogicalWidth = logicalWidth;

  clearPreferredLogicalWidthsDirty();

  updateMargins();
}
void LayoutListMarker::updateContent()
{
    // FIXME: This if-statement is just a performance optimization, but it's messy to use the preferredLogicalWidths dirty bit for this.
    // It's unclear if this is a premature optimization.
    if (!preferredLogicalWidthsDirty())
        return;

    m_text = "";

    if (isImage())
        return;

    switch (listStyleCategory()) {
    case ListStyleCategory::None:
        break;
    case ListStyleCategory::Symbol:
        m_text = ListMarkerText::text(style()->listStyleType(), 0); // value is ignored for these types
        break;
    case ListStyleCategory::Language:
        m_text = ListMarkerText::text(style()->listStyleType(), m_listItem->value());
        break;
    }
}
Esempio n. 16
0
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);
}
Esempio n. 17
0
void RenderHTMLCanvas::canvasSizeChanged()
{
    IntSize canvasSize = toHTMLCanvasElement(node())->size();

    if (canvasSize == intrinsicSize())
        return;

    setIntrinsicSize(canvasSize);

    if (!parent())
        return;

    if (!preferredLogicalWidthsDirty())
        setPreferredLogicalWidthsDirty();

    LayoutSize oldSize = size();
    updateLogicalWidth();
    updateLogicalHeight();
    if (oldSize == size())
        return;

    if (!selfNeedsLayout())
        setNeedsLayoutAndFullPaintInvalidation();
}