| 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.localSVGTransform()); | 43 m_layoutSVGForeignObject.localToSVGParentTransform()); |
| 44 SVGTransformContext transformContext( | 44 SVGTransformContext transformContext( |
| 45 paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, | 45 paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, |
| 46 m_layoutSVGForeignObject.localSVGTransform()); | 46 m_layoutSVGForeignObject.localToSVGParentTransform()); |
| 47 | 47 |
| 48 Optional<FloatClipRecorder> clipRecorder; | 48 Optional<FloatClipRecorder> clipRecorder; |
| 49 if (SVGLayoutSupport::isOverflowHidden(&m_layoutSVGForeignObject)) | 49 if (SVGLayoutSupport::isOverflowHidden(&m_layoutSVGForeignObject)) { |
| 50 clipRecorder.emplace(paintInfoBeforeFiltering.context, | 50 clipRecorder.emplace( |
| 51 m_layoutSVGForeignObject, | 51 paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, |
| 52 paintInfoBeforeFiltering.phase, | 52 paintInfoBeforeFiltering.phase, |
| 53 m_layoutSVGForeignObject.viewportRect()); | 53 FloatRect(FloatPoint(), |
| 54 m_layoutSVGForeignObject.viewportRect().size())); |
| 55 } |
| 54 | 56 |
| 55 SVGPaintContext paintContext(m_layoutSVGForeignObject, | 57 SVGPaintContext paintContext(m_layoutSVGForeignObject, |
| 56 paintInfoBeforeFiltering); | 58 paintInfoBeforeFiltering); |
| 57 bool continueRendering = true; | 59 bool continueRendering = true; |
| 58 if (paintContext.paintInfo().phase == PaintPhaseForeground) | 60 if (paintContext.paintInfo().phase == PaintPhaseForeground) |
| 59 continueRendering = paintContext.applyClipMaskAndFilterIfNecessary(); | 61 continueRendering = paintContext.applyClipMaskAndFilterIfNecessary(); |
| 60 | 62 |
| 61 if (continueRendering) { | 63 if (continueRendering) { |
| 62 // Paint all phases of FO elements atomically as though the FO element | 64 // Paint all phases of FO elements atomically as though the FO element |
| 63 // established its own stacking context. The delegate forwards calls to | 65 // established its own stacking context. The delegate forwards calls to |
| 64 // paint() in LayoutObject::paintAllPhasesAtomically() to | 66 // paint() in LayoutObject::paintAllPhasesAtomically() to |
| 65 // BlockPainter::paint(), instead of m_layoutSVGForeignObject.paint() (which | 67 // BlockPainter::paint(), instead of m_layoutSVGForeignObject.paint() (which |
| 66 // would call this method again). | 68 // would call this method again). |
| 67 BlockPainterDelegate delegate(m_layoutSVGForeignObject); | 69 BlockPainterDelegate delegate(m_layoutSVGForeignObject); |
| 68 ObjectPainter(delegate).paintAllPhasesAtomically(paintContext.paintInfo(), | 70 // We have included location() in transform, so pass -location() to adjust |
| 69 LayoutPoint()); | 71 // paint offset that will be added by location() in BlockPainter::paint(). |
| 72 ObjectPainter(delegate).paintAllPhasesAtomically( |
| 73 paintContext.paintInfo(), -m_layoutSVGForeignObject.location()); |
| 70 } | 74 } |
| 71 } | 75 } |
| 72 | 76 |
| 73 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |