OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "core/paint/SVGContainerPainter.h" | |
7 | |
8 #include "core/frame/Settings.h" | |
9 #include "core/paint/ObjectPainter.h" | |
10 #include "core/rendering/GraphicsContextAnnotator.h" | |
11 #include "core/rendering/PaintInfo.h" | |
12 #include "core/rendering/svg/RenderSVGContainer.h" | |
13 #include "core/rendering/svg/RenderSVGViewportContainer.h" | |
14 #include "core/rendering/svg/SVGRenderSupport.h" | |
15 #include "core/rendering/svg/SVGRenderingContext.h" | |
16 #include "core/svg/SVGSVGElement.h" | |
17 #include "platform/graphics/GraphicsContextCullSaver.h" | |
18 #include "platform/graphics/GraphicsContextStateSaver.h" | |
19 | |
20 namespace blink { | |
21 | |
22 void SVGContainerPainter::paint(PaintInfo& paintInfo) | |
23 { | |
24 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderSVGContainer); | |
25 | |
26 // Spec: groups w/o children still may render filter content. | |
27 if (!m_renderSVGContainer.firstChild() && !m_renderSVGContainer.selfWillPain t()) | |
28 return; | |
29 | |
30 FloatRect paintInvalidationRect = m_renderSVGContainer.paintInvalidationRect InLocalCoordinates(); | |
31 if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(paintInvalid ationRect, m_renderSVGContainer.localToParentTransform(), paintInfo)) | |
32 return; | |
33 | |
34 // Spec: An empty viewBox on the <svg> element disables rendering. | |
35 ASSERT(m_renderSVGContainer.element()); | |
36 if (isSVGSVGElement(*m_renderSVGContainer.element()) && toSVGSVGElement(*m_r enderSVGContainer.element()).hasEmptyViewBox()) | |
37 return; | |
38 | |
39 PaintInfo childPaintInfo(paintInfo); | |
40 { | |
41 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); | |
42 | |
43 if (m_renderSVGContainer.isSVGViewportContainer() && SVGRenderSupport::i sOverflowHidden(&m_renderSVGContainer)) | |
f(malita)
2014/09/25 13:42:50
If we're going to do this, can we handle it in Ren
| |
44 paintInfo.context->clip(toRenderSVGViewportContainer(m_renderSVGCont ainer).viewport()); | |
45 | |
46 childPaintInfo.applyTransform(m_renderSVGContainer.localToParentTransfor m()); | |
47 | |
48 SVGRenderingContext renderingContext; | |
49 GraphicsContextCullSaver cullSaver(*childPaintInfo.context); | |
50 bool continueRendering = true; | |
51 if (childPaintInfo.phase == PaintPhaseForeground) { | |
52 renderingContext.prepareToRenderSVGContent(&m_renderSVGContainer, ch ildPaintInfo); | |
53 continueRendering = renderingContext.isRenderingPrepared(); | |
54 | |
55 if (continueRendering && m_renderSVGContainer.document().settings()- >containerCullingEnabled()) | |
56 cullSaver.cull(m_renderSVGContainer.paintInvalidationRectInLocal Coordinates()); | |
57 } | |
58 | |
59 if (continueRendering) { | |
60 childPaintInfo.updatePaintingRootForChildren(&m_renderSVGContainer); | |
61 for (RenderObject* child = m_renderSVGContainer.firstChild(); child; child = child->nextSibling()) | |
62 child->paint(childPaintInfo, IntPoint()); | |
63 } | |
64 } | |
65 | |
66 // FIXME: This really should be drawn from local coordinates, but currently we hack it | |
67 // to avoid our clip killing our outline rect. Thus we translate our | |
68 // outline rect into parent coords before drawing. | |
69 // FIXME: This means our focus ring won't share our rotation like it should. | |
70 // We should instead disable our clip during PaintPhaseOutline | |
71 if (paintInfo.phase == PaintPhaseForeground && m_renderSVGContainer.style()- >outlineWidth() && m_renderSVGContainer.style()->visibility() == VISIBLE) { | |
72 IntRect paintRectInParent = enclosingIntRect(m_renderSVGContainer.localT oParentTransform().mapRect(paintInvalidationRect)); | |
73 ObjectPainter(m_renderSVGContainer).paintOutline(paintInfo, paintRectInP arent); | |
74 } | |
75 } | |
76 | |
77 } // namespace blink | |
OLD | NEW |