Esempio n. 1
0
void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(
    const FloatingObject& newFloat) {
  LayoutUnit height = m_block.logicalHeight();
  if (height < m_block.logicalTopForFloat(newFloat) ||
      height >= m_block.logicalBottomForFloat(newFloat))
    return;

  ShapeOutsideDeltas shapeDeltas;
  if (ShapeOutsideInfo* shapeOutsideInfo =
          newFloat.layoutObject()->shapeOutsideInfo()) {
    LayoutUnit lineHeight = m_block.lineHeight(
        m_isFirstLine,
        m_block.isHorizontalWritingMode() ? HorizontalLine : VerticalLine,
        PositionOfInteriorLineBoxes);
    shapeDeltas = shapeOutsideInfo->computeDeltasForContainingBlockLine(
        m_block, newFloat, m_block.logicalHeight(), lineHeight);
  }

  if (newFloat.getType() == FloatingObject::FloatLeft) {
    LayoutUnit newLeft = m_block.logicalRightForFloat(newFloat);
    if (shapeDeltas.isValid()) {
      if (shapeDeltas.lineOverlapsShape()) {
        newLeft += shapeDeltas.rightMarginBoxDelta();
      } else {
        // Per the CSS Shapes spec, If the line doesn't overlap the shape, then
        // ignore this shape for this line.
        newLeft = m_left;
      }
    }
    if (indentText() == IndentText && m_block.style()->isLeftToRightDirection())
      newLeft += floorToInt(m_block.textIndentOffset());
    m_left = std::max(m_left, newLeft);
  } else {
    LayoutUnit newRight = m_block.logicalLeftForFloat(newFloat);
    if (shapeDeltas.isValid()) {
      if (shapeDeltas.lineOverlapsShape()) {
        newRight += shapeDeltas.leftMarginBoxDelta();
      } else {
        // Per the CSS Shapes spec, If the line doesn't overlap the shape, then
        // ignore this shape for this line.
        newRight = m_right;
      }
    }
    if (indentText() == IndentText &&
        !m_block.style()->isLeftToRightDirection())
      newRight -= floorToInt(m_block.textIndentOffset());
    m_right = std::min(m_right, newRight);
  }

  computeAvailableWidthFromLeftAndRight();
}
Esempio n. 2
0
void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat)
{
    LayoutUnit height = m_block.logicalHeight();
    if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logicalBottomForFloat(newFloat))
        return;

#if ENABLE(CSS_SHAPES)
    ShapeOutsideDeltas shapeDeltas;
    if (ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer().shapeOutsideInfo()) {
        LayoutUnit lineHeight = m_block.lineHeight(m_isFirstLine, m_block.isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
        shapeDeltas = shapeOutsideInfo->computeDeltasForContainingBlockLine(m_block, *newFloat, m_block.logicalHeight(), lineHeight);
    }
#endif

    if (newFloat->type() == FloatingObject::FloatLeft) {
        float newLeft = m_block.logicalRightForFloat(newFloat);
        if (shouldIndentText() && m_block.style().isLeftToRightDirection())
            newLeft += floorToInt(m_block.textIndentOffset());
#if ENABLE(CSS_SHAPES)
        if (shapeDeltas.isValid()) {
            if (shapeDeltas.lineOverlapsShape())
                newLeft += shapeDeltas.rightMarginBoxDelta();
            else // If the line doesn't overlap the shape, then we need to act as if this float didn't exist.
                newLeft = m_left;
        }
#endif
        m_left = std::max<float>(m_left, newLeft);
    } else {
        float newRight = m_block.logicalLeftForFloat(newFloat);
        if (shouldIndentText() && !m_block.style().isLeftToRightDirection())
            newRight -= floorToInt(m_block.textIndentOffset());
#if ENABLE(CSS_SHAPES)
        if (shapeDeltas.isValid()) {
            if (shapeDeltas.lineOverlapsShape())
                newRight += shapeDeltas.leftMarginBoxDelta();
            else // If the line doesn't overlap the shape, then we need to act as if this float didn't exist.
                newRight = m_right;
        }
#endif
        m_right = std::min<float>(m_right, newRight);
    }

    computeAvailableWidthFromLeftAndRight();
}
Esempio n. 3
0
inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
    LayoutUnit logicalLeft = m_layoutObject->logicalLeftForFloat(floatingObject);
    if (ShapeOutsideInfo* shapeOutside = floatingObject.layoutObject()->shapeOutsideInfo()) {
        ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainingBlockLine(LineLayoutBlockFlow(const_cast<LayoutBlockFlow*>(m_layoutObject)), floatingObject, m_lineTop, m_lineBottom - m_lineTop);
        if (!shapeDeltas.lineOverlapsShape())
            return false;

        logicalLeft += shapeDeltas.leftMarginBoxDelta();
    }
    if (logicalLeft < m_offset) {
        m_offset = logicalLeft;
        return true;
    }

    return false;
}
Esempio n. 4
0
inline bool ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft>::updateOffsetIfNeeded(const FloatingObject& floatingObject)
{
    LayoutUnit logicalRight = m_renderer.logicalRightForFloat(floatingObject);
    if (ShapeOutsideInfo* shapeOutside = floatingObject.renderer().shapeOutsideInfo()) {
        ShapeOutsideDeltas shapeDeltas = shapeOutside->computeDeltasForContainingBlockLine(m_renderer, floatingObject, m_lineTop, m_lineBottom - m_lineTop);
        if (!shapeDeltas.lineOverlapsShape())
            return false;

        logicalRight += shapeDeltas.rightMarginBoxDelta();
    }
    if (logicalRight > m_offset) {
        m_offset = logicalRight;
        return true;
    }

    return false;
}