blob: 94e198a4a9d4744583cfe22d1de49311c4a60b22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// 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 "core/paint/SVGContainerPainter.h"
#include "core/layout/svg/LayoutSVGContainer.h"
#include "core/layout/svg/LayoutSVGViewportContainer.h"
#include "core/layout/svg/SVGLayoutSupport.h"
#include "core/paint/FloatClipRecorder.h"
#include "core/paint/ObjectPainter.h"
#include "core/paint/PaintInfo.h"
#include "core/paint/SVGPaintContext.h"
#include "core/paint/TransformRecorder.h"
#include "core/svg/SVGSVGElement.h"
#include "wtf/Optional.h"
namespace blink {
void SVGContainerPainter::paint(const PaintInfo& paintInfo)
{
// Spec: groups w/o children still may render filter content.
if (!m_layoutSVGContainer.firstChild() && !m_layoutSVGContainer.selfWillPaint())
return;
FloatRect boundingBox = m_layoutSVGContainer.paintInvalidationRectInLocalSVGCoordinates();
if (!paintInfo.cullRect().intersectsCullRect(m_layoutSVGContainer.localToSVGParentTransform(), boundingBox))
return;
// Spec: An empty viewBox on the <svg> element disables rendering.
ASSERT(m_layoutSVGContainer.element());
if (isSVGSVGElement(*m_layoutSVGContainer.element()) && toSVGSVGElement(*m_layoutSVGContainer.element()).hasEmptyViewBox())
return;
PaintInfo paintInfoBeforeFiltering(paintInfo);
paintInfoBeforeFiltering.updateCullRect(m_layoutSVGContainer.localToSVGParentTransform());
TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layoutSVGContainer, m_layoutSVGContainer.localToSVGParentTransform());
{
Optional<FloatClipRecorder> clipRecorder;
if (m_layoutSVGContainer.isSVGViewportContainer() && SVGLayoutSupport::isOverflowHidden(&m_layoutSVGContainer)) {
FloatRect viewport = m_layoutSVGContainer.localToSVGParentTransform().inverse().mapRect(toLayoutSVGViewportContainer(m_layoutSVGContainer).viewport());
clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGContainer, paintInfoBeforeFiltering.phase, viewport);
}
SVGPaintContext paintContext(m_layoutSVGContainer, paintInfoBeforeFiltering);
bool continueRendering = true;
if (paintContext.paintInfo().phase == PaintPhaseForeground)
continueRendering = paintContext.applyClipMaskAndFilterIfNecessary();
if (continueRendering) {
for (LayoutObject* child = m_layoutSVGContainer.firstChild(); child; child = child->nextSibling())
child->paint(paintContext.paintInfo(), IntPoint());
}
}
if (paintInfoBeforeFiltering.phase != PaintPhaseForeground)
return;
if (m_layoutSVGContainer.style()->outlineWidth() && m_layoutSVGContainer.style()->visibility() == VISIBLE) {
PaintInfo outlinePaintInfo(paintInfoBeforeFiltering);
outlinePaintInfo.phase = PaintPhaseSelfOutlineOnly;
ObjectPainter(m_layoutSVGContainer).paintOutline(outlinePaintInfo, LayoutPoint(boundingBox.location()));
}
if (paintInfoBeforeFiltering.isPrinting())
ObjectPainter(m_layoutSVGContainer).addPDFURLRectIfNeeded(paintInfoBeforeFiltering, LayoutPoint());
}
} // namespace blink
|