OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/paint/SVGForeignObjectPainter.h" | 5 #include "core/paint/SVGForeignObjectPainter.h" |
6 | 6 |
7 #include "core/layout/svg/LayoutSVGForeignObject.h" | 7 #include "core/layout/svg/LayoutSVGForeignObject.h" |
8 #include "core/layout/svg/SVGLayoutSupport.h" | 8 #include "core/layout/svg/SVGLayoutSupport.h" |
9 #include "core/paint/BlockPainter.h" | 9 #include "core/paint/BlockPainter.h" |
10 #include "core/paint/FloatClipRecorder.h" | 10 #include "core/paint/FloatClipRecorder.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 void SVGForeignObjectPainter::paint(const PaintInfo& paintInfo) { | 36 void SVGForeignObjectPainter::paint(const PaintInfo& paintInfo) { |
37 if (paintInfo.phase != PaintPhaseForeground && | 37 if (paintInfo.phase != PaintPhaseForeground && |
38 paintInfo.phase != PaintPhaseSelection) | 38 paintInfo.phase != PaintPhaseSelection) |
39 return; | 39 return; |
40 | 40 |
41 PaintInfo paintInfoBeforeFiltering(paintInfo); | 41 PaintInfo paintInfoBeforeFiltering(paintInfo); |
42 paintInfoBeforeFiltering.updateCullRect( | 42 paintInfoBeforeFiltering.updateCullRect( |
43 m_layoutSVGForeignObject.localToSVGParentTransform()); | 43 m_layoutSVGForeignObject.localSVGTransform()); |
44 SVGTransformContext transformContext( | 44 SVGTransformContext transformContext( |
45 paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, | 45 paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, |
46 m_layoutSVGForeignObject.localToSVGParentTransform()); | 46 m_layoutSVGForeignObject.localSVGTransform()); |
47 | 47 |
48 // In theory we should just let BlockPainter::paint() handle the clip, but for | 48 // In theory we should just let BlockPainter::paint() handle the clip, but for |
49 // now we don't allow normal overflow clip for LayoutSVGBlock, so we have to | 49 // now we don't allow normal overflow clip for LayoutSVGBlock, so we have to |
50 // apply clip manually. See LayoutSVGBlock::allowsOverflowClip() for details. | 50 // apply clip manually. See LayoutSVGBlock::allowsOverflowClip() for details. |
51 Optional<FloatClipRecorder> clipRecorder; | 51 Optional<FloatClipRecorder> clipRecorder; |
52 if (SVGLayoutSupport::isOverflowHidden(&m_layoutSVGForeignObject)) { | 52 if (SVGLayoutSupport::isOverflowHidden(&m_layoutSVGForeignObject)) { |
53 clipRecorder.emplace( | 53 clipRecorder.emplace(paintInfoBeforeFiltering.context, |
54 paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, | 54 m_layoutSVGForeignObject, |
55 paintInfoBeforeFiltering.phase, | 55 paintInfoBeforeFiltering.phase, |
56 m_layoutSVGForeignObject.visualRectInLocalSVGCoordinates()); | 56 FloatRect(m_layoutSVGForeignObject.frameRect())); |
57 } | 57 } |
58 | 58 |
59 SVGPaintContext paintContext(m_layoutSVGForeignObject, | 59 SVGPaintContext paintContext(m_layoutSVGForeignObject, |
60 paintInfoBeforeFiltering); | 60 paintInfoBeforeFiltering); |
61 bool continueRendering = true; | 61 bool continueRendering = true; |
62 if (paintContext.paintInfo().phase == PaintPhaseForeground) | 62 if (paintContext.paintInfo().phase == PaintPhaseForeground) |
63 continueRendering = paintContext.applyClipMaskAndFilterIfNecessary(); | 63 continueRendering = paintContext.applyClipMaskAndFilterIfNecessary(); |
64 | 64 |
65 if (continueRendering) { | 65 if (continueRendering) { |
66 // Paint all phases of FO elements atomically as though the FO element | 66 // Paint all phases of FO elements atomically as though the FO element |
67 // established its own stacking context. The delegate forwards calls to | 67 // established its own stacking context. The delegate forwards calls to |
68 // paint() in LayoutObject::paintAllPhasesAtomically() to | 68 // paint() in LayoutObject::paintAllPhasesAtomically() to |
69 // BlockPainter::paint(), instead of m_layoutSVGForeignObject.paint() (which | 69 // BlockPainter::paint(), instead of m_layoutSVGForeignObject.paint() (which |
70 // would call this method again). | 70 // would call this method again). |
71 BlockPainterDelegate delegate(m_layoutSVGForeignObject); | 71 BlockPainterDelegate delegate(m_layoutSVGForeignObject); |
72 // We have included location() in transform, so pass -location() to adjust | 72 ObjectPainter(delegate).paintAllPhasesAtomically(paintContext.paintInfo(), |
73 // paint offset that will be added by location() in BlockPainter::paint(). | 73 LayoutPoint()); |
74 ObjectPainter(delegate).paintAllPhasesAtomically( | |
75 paintContext.paintInfo(), -m_layoutSVGForeignObject.location()); | |
76 } | 74 } |
77 } | 75 } |
78 | 76 |
79 } // namespace blink | 77 } // namespace blink |
OLD | NEW |