Ejemplo n.º 1
0
void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
    Optional<SubtreeRecorder> subtreeRecorder;
    if (needsSubtreeRecorder(m_layoutBlock)) {
        subtreeRecorder.emplace(*paintInfo.context, m_layoutBlock, paintInfo.phase);
        if (subtreeRecorder->canUseCache())
            return;
    }

    PaintInfo localPaintInfo(paintInfo);

    LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location();

    PaintPhase originalPhase = localPaintInfo.phase;

    // Check if we need to do anything at all.
    LayoutRect overflowBox = overflowRectForPaintRejection();
    m_layoutBlock.flipForWritingMode(overflowBox);
    overflowBox.moveBy(adjustedPaintOffset);
    if (!overflowBox.intersects(LayoutRect(localPaintInfo.rect)))
        return;

    // There are some cases where not all clipped visual overflow is accounted for.
    // FIXME: reduce the number of such cases.
    ContentsClipBehavior contentsClipBehavior = ForceContentsClip;
    if (m_layoutBlock.hasOverflowClip() && !m_layoutBlock.hasControlClip() && !(m_layoutBlock.shouldPaintSelectionGaps() && originalPhase == PaintPhaseForeground) && !hasCaret())
        contentsClipBehavior = SkipContentsClipIfPossible;

    if (localPaintInfo.phase == PaintPhaseOutline) {
        localPaintInfo.phase = PaintPhaseChildOutlines;
    } else if (localPaintInfo.phase == PaintPhaseChildBlockBackground) {
        localPaintInfo.phase = PaintPhaseBlockBackground;
        m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset);
        localPaintInfo.phase = PaintPhaseChildBlockBackgrounds;
    }

    {
        BoxClipper boxClipper(m_layoutBlock, localPaintInfo, adjustedPaintOffset, contentsClipBehavior);
        m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset);
    }

    if (originalPhase == PaintPhaseOutline) {
        localPaintInfo.phase = PaintPhaseSelfOutline;
        m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset);
        localPaintInfo.phase = originalPhase;
    } else if (originalPhase == PaintPhaseChildBlockBackground) {
        localPaintInfo.phase = originalPhase;
    }

    // Our scrollbar widgets paint exactly when we tell them to, so that they work properly with
    // z-index. We paint after we painted the background/border, so that the scrollbars will
    // sit above the background/border.
    paintOverflowControlsIfNeeded(localPaintInfo, adjustedPaintOffset);
}
Ejemplo n.º 2
0
void BlockPainter::paint(const PaintInfo& paintInfo,
                         const LayoutPoint& paintOffset) {
  LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location();
  if (!intersectsPaintRect(paintInfo, adjustedPaintOffset))
    return;

  PaintInfo localPaintInfo(paintInfo);
  PaintPhase originalPhase = localPaintInfo.phase;

  // There are some cases where not all clipped visual overflow is accounted
  // for.
  // FIXME: reduce the number of such cases.
  ContentsClipBehavior contentsClipBehavior = ForceContentsClip;
  if (m_layoutBlock.hasOverflowClip() && !m_layoutBlock.hasControlClip() &&
      !m_layoutBlock.hasCaret())
    contentsClipBehavior = SkipContentsClipIfPossible;

  if (originalPhase == PaintPhaseOutline) {
    localPaintInfo.phase = PaintPhaseDescendantOutlinesOnly;
  } else if (shouldPaintSelfBlockBackground(originalPhase)) {
    localPaintInfo.phase = PaintPhaseSelfBlockBackgroundOnly;
    m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset);
    if (shouldPaintDescendantBlockBackgrounds(originalPhase))
      localPaintInfo.phase = PaintPhaseDescendantBlockBackgroundsOnly;
  }

  if (originalPhase != PaintPhaseSelfBlockBackgroundOnly &&
      originalPhase != PaintPhaseSelfOutlineOnly) {
    BoxClipper boxClipper(m_layoutBlock, localPaintInfo, adjustedPaintOffset,
                          contentsClipBehavior);
    m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset);
  }

  if (shouldPaintSelfOutline(originalPhase)) {
    localPaintInfo.phase = PaintPhaseSelfOutlineOnly;
    m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset);
  }

  // Our scrollbar widgets paint exactly when we tell them to, so that they work
  // properly with z-index. We paint after we painted the background/border, so
  // that the scrollbars will sit above the background/border.
  localPaintInfo.phase = originalPhase;
  paintOverflowControlsIfNeeded(localPaintInfo, adjustedPaintOffset);
}
Ejemplo n.º 3
0
void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
    if (!intersectsPaintRect(paintInfo, paintOffset))
        return;

    LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location();
    PaintInfo localPaintInfo(paintInfo);
    PaintPhase originalPhase = localPaintInfo.phase;

    // There are some cases where not all clipped visual overflow is accounted for.
    // FIXME: reduce the number of such cases.
    ContentsClipBehavior contentsClipBehavior = ForceContentsClip;
    if (m_layoutBlock.hasOverflowClip() && !m_layoutBlock.hasControlClip() && !(m_layoutBlock.shouldPaintSelectionGaps() && originalPhase == PaintPhaseForeground) && !m_layoutBlock.hasCaret())
        contentsClipBehavior = SkipContentsClipIfPossible;

    if (localPaintInfo.phase == PaintPhaseOutline) {
        localPaintInfo.phase = PaintPhaseChildOutlines;
    } else if (localPaintInfo.phase == PaintPhaseChildBlockBackground) {
        localPaintInfo.phase = PaintPhaseBlockBackground;
        m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset);
        localPaintInfo.phase = PaintPhaseChildBlockBackgrounds;
    }

    {
        BoxClipper boxClipper(m_layoutBlock, localPaintInfo, adjustedPaintOffset, contentsClipBehavior);
        m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset);
    }

    if (originalPhase == PaintPhaseOutline) {
        localPaintInfo.phase = PaintPhaseSelfOutline;
        m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset);
        localPaintInfo.phase = originalPhase;
    } else if (originalPhase == PaintPhaseChildBlockBackground) {
        localPaintInfo.phase = originalPhase;
    }

    // Our scrollbar widgets paint exactly when we tell them to, so that they work properly with
    // z-index. We paint after we painted the background/border, so that the scrollbars will
    // sit above the background/border.
    paintOverflowControlsIfNeeded(localPaintInfo, adjustedPaintOffset);
}