Index: Source/core/paint/PartPainter.cpp |
diff --git a/Source/core/paint/PartPainter.cpp b/Source/core/paint/PartPainter.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..64bd69246c6f107004b7670c9a40ce265e9038ae |
--- /dev/null |
+++ b/Source/core/paint/PartPainter.cpp |
@@ -0,0 +1,130 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/paint/PartPainter.h" |
+ |
+#include "core/frame/FrameView.h" |
+#include "core/paint/BoxPainter.h" |
+#include "core/paint/ClipRecorder.h" |
+#include "core/paint/DrawingRecorder.h" |
+#include "core/paint/TranslationRecorder.h" |
+#include "core/paint/ViewDisplayList.h" |
+#include "core/rendering/GraphicsContextAnnotator.h" |
+#include "core/rendering/PaintInfo.h" |
+#include "core/rendering/RenderLayer.h" |
+#include "core/rendering/RenderPart.h" |
+ |
+namespace blink { |
+ |
+void PartPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
+{ |
+ ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderPart); |
+ |
+ if (!m_renderPart.shouldPaint(paintInfo, paintOffset)) |
+ return; |
+ |
+ LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location(); |
+ |
+ LayoutRect bounds; |
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
+ bounds = m_renderPart.visualOverflowRect(); |
+ bounds.moveBy(paintOffset); |
+ } |
+ |
+ if (m_renderPart.hasBoxDecorationBackground() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection)) { |
+ DrawingRecorder recorder(paintInfo.context, &m_renderPart, paintInfo.phase, bounds); |
+ m_renderPart.paintBoxDecorationBackground(paintInfo, adjustedPaintOffset); |
+ } |
+ |
+ if (paintInfo.phase == PaintPhaseMask) { |
+ DrawingRecorder recorder(paintInfo.context, &m_renderPart, paintInfo.phase, bounds); |
+ m_renderPart.paintMask(paintInfo, adjustedPaintOffset); |
+ return; |
+ } |
+ |
+ if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && m_renderPart.style()->hasOutline()) { |
+ DrawingRecorder recorder(paintInfo.context, &m_renderPart, paintInfo.phase, bounds); |
+ m_renderPart.paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, m_renderPart.size())); |
+ } |
+ |
+ if (paintInfo.phase != PaintPhaseForeground) |
+ return; |
+ |
+ OwnPtr<ClipRecorder> clipRecorder; |
+ if (m_renderPart.style()->hasBorderRadius()) { |
+ LayoutRect borderRect = LayoutRect(adjustedPaintOffset, m_renderPart.size()); |
+ if (borderRect.isEmpty()) |
+ return; |
+ |
+ RoundedRect roundedInnerRect = m_renderPart.style()->getRoundedInnerBorderFor(borderRect, |
+ m_renderPart.paddingTop() + m_renderPart.borderTop(), |
+ m_renderPart.paddingBottom() + m_renderPart.borderBottom(), |
+ m_renderPart.paddingLeft() + m_renderPart.borderLeft(), |
+ m_renderPart.paddingRight() + m_renderPart.borderRight(), true, true); |
+ |
+ // FIXME: Need a proper identifier (layer and phase pair) for this clip item. |
+ clipRecorder = adoptPtr(new ClipRecorder(m_renderPart.layer(), paintInfo.context, DisplayItem::ClipLayerFragmentForeground, borderRect)); |
+ // FIXME: Copied from BoxPainter::clipRoundedInnerRect. Should make it work with ClipRecorder. |
+ if (roundedInnerRect.isRenderable()) { |
+ clipRecorder->addRoundedRectClip(roundedInnerRect); |
+ } else { |
+ if (!roundedInnerRect.radii().topLeft().isEmpty() || !roundedInnerRect.radii().bottomRight().isEmpty()) { |
+ IntRect topCorner(roundedInnerRect.rect().x(), roundedInnerRect.rect().y(), borderRect.maxX() - roundedInnerRect.rect().x(), borderRect.maxY() - roundedInnerRect.rect().y()); |
+ RoundedRect::Radii topCornerRadii; |
+ topCornerRadii.setTopLeft(roundedInnerRect.radii().topLeft()); |
+ clipRecorder->addRoundedRectClip(RoundedRect(topCorner, topCornerRadii)); |
+ |
+ IntRect bottomCorner(borderRect.x(), borderRect.y(), roundedInnerRect.rect().maxX() - borderRect.x(), roundedInnerRect.rect().maxY() - borderRect.y()); |
+ RoundedRect::Radii bottomCornerRadii; |
+ bottomCornerRadii.setBottomRight(roundedInnerRect.radii().bottomRight()); |
+ clipRecorder->addRoundedRectClip(RoundedRect(bottomCorner, bottomCornerRadii)); |
+ } |
+ |
+ if (!roundedInnerRect.radii().topRight().isEmpty() || !roundedInnerRect.radii().bottomLeft().isEmpty()) { |
+ IntRect topCorner(borderRect.x(), roundedInnerRect.rect().y(), roundedInnerRect.rect().maxX() - borderRect.x(), borderRect.maxY() - roundedInnerRect.rect().y()); |
+ RoundedRect::Radii topCornerRadii; |
+ topCornerRadii.setTopRight(roundedInnerRect.radii().topRight()); |
+ clipRecorder->addRoundedRectClip(RoundedRect(topCorner, topCornerRadii)); |
+ |
+ IntRect bottomCorner(roundedInnerRect.rect().x(), borderRect.y(), borderRect.maxX() - roundedInnerRect.rect().x(), roundedInnerRect.rect().maxY() - borderRect.y()); |
+ RoundedRect::Radii bottomCornerRadii; |
+ bottomCornerRadii.setBottomLeft(roundedInnerRect.radii().bottomLeft()); |
+ clipRecorder->addRoundedRectClip(RoundedRect(bottomCorner, bottomCornerRadii)); |
+ } |
+ } |
+ } |
+ |
+ paintContents(paintInfo, paintOffset); |
+ |
+ clipRecorder.clear(); |
+ |
+ DrawingRecorder recorder(paintInfo.context, &m_renderPart, paintInfo.phase, bounds); |
+ // Paint a partially transparent wash over selected widgets. |
+ if (m_renderPart.isSelected() && !m_renderPart.document().printing()) { |
+ LayoutRect rect = m_renderPart.localSelectionRect(); |
+ rect.moveBy(adjustedPaintOffset); |
+ paintInfo.context->fillRect(pixelSnappedIntRect(rect), m_renderPart.selectionBackgroundColor()); |
+ } |
+ |
+ if (m_renderPart.canResize()) |
+ m_renderPart.layer()->scrollableArea()->paintResizer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect); |
+} |
+ |
+void PartPainter::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
+{ |
+ if (!m_renderPart.widget()) |
+ return; |
+ Widget* widget = m_renderPart.widget(); |
+ |
+ LayoutPoint adjustedPaintOffset = paintOffset + m_renderPart.location() + m_renderPart.contentBoxRect().location(); |
+ IntSize widgetPaintOffset = roundedIntPoint(adjustedPaintOffset) - widget->frameRect().location(); |
+ |
+ TranslationRecorder translationRecorder(&m_renderPart, paintInfo.context, widgetPaintOffset); |
+ IntRect paintRect = paintInfo.rect; |
+ paintRect.move(-widgetPaintOffset); |
+ widget->paint(paintInfo.context, paintRect); |
+} |
+ |
+} // namespace blink |