Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1638)

Unified Diff: Source/core/paint/PartPainter.cpp

Issue 698743002: [WIP] Adding support for <iframe>s to slimming paint. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698