| 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" |
| 11 #include "core/paint/ObjectPainter.h" | |
| 12 #include "core/paint/PaintInfo.h" | 11 #include "core/paint/PaintInfo.h" |
| 13 #include "core/paint/SVGPaintContext.h" | 12 #include "core/paint/SVGPaintContext.h" |
| 14 #include "core/paint/TransformRecorder.h" | 13 #include "core/paint/TransformRecorder.h" |
| 15 #include "wtf/Optional.h" | 14 #include "wtf/Optional.h" |
| 16 | 15 |
| 17 namespace blink { | 16 namespace blink { |
| 18 | 17 |
| 19 namespace { | |
| 20 | |
| 21 class BlockPainterDelegate : public LayoutBlock { | |
| 22 public: | |
| 23 BlockPainterDelegate(const LayoutSVGForeignObject& layoutSVGForeignObject) | |
| 24 : LayoutBlock(nullptr) | |
| 25 , m_layoutSVGForeignObject(layoutSVGForeignObject) | |
| 26 { } | |
| 27 | |
| 28 private: | |
| 29 void paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) const
final | |
| 30 { | |
| 31 BlockPainter(m_layoutSVGForeignObject).paint(paintInfo, paintOffset); | |
| 32 } | |
| 33 const LayoutSVGForeignObject& m_layoutSVGForeignObject; | |
| 34 }; | |
| 35 | |
| 36 } // namespace | |
| 37 | |
| 38 void SVGForeignObjectPainter::paint(const PaintInfo& paintInfo) | 18 void SVGForeignObjectPainter::paint(const PaintInfo& paintInfo) |
| 39 { | 19 { |
| 40 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Selection) | 20 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Selection) |
| 41 return; | 21 return; |
| 42 | 22 |
| 43 PaintInfo paintInfoBeforeFiltering(paintInfo); | 23 PaintInfo paintInfoBeforeFiltering(paintInfo); |
| 44 paintInfoBeforeFiltering.updateCullRect(m_layoutSVGForeignObject.localTransf
orm()); | 24 paintInfoBeforeFiltering.updateCullRect(m_layoutSVGForeignObject.localTransf
orm()); |
| 45 TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layo
utSVGForeignObject, m_layoutSVGForeignObject.localTransform()); | 25 TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layo
utSVGForeignObject, m_layoutSVGForeignObject.localTransform()); |
| 46 | 26 |
| 47 Optional<FloatClipRecorder> clipRecorder; | 27 Optional<FloatClipRecorder> clipRecorder; |
| 48 if (SVGLayoutSupport::isOverflowHidden(&m_layoutSVGForeignObject)) | 28 if (SVGLayoutSupport::isOverflowHidden(&m_layoutSVGForeignObject)) |
| 49 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGForeig
nObject, paintInfoBeforeFiltering.phase, m_layoutSVGForeignObject.viewportRect()
); | 29 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGForeig
nObject, paintInfoBeforeFiltering.phase, m_layoutSVGForeignObject.viewportRect()
); |
| 50 | 30 |
| 51 SVGPaintContext paintContext(m_layoutSVGForeignObject, paintInfoBeforeFilter
ing); | 31 SVGPaintContext paintContext(m_layoutSVGForeignObject, paintInfoBeforeFilter
ing); |
| 52 bool continueRendering = true; | 32 bool continueRendering = true; |
| 53 if (paintContext.paintInfo().phase == PaintPhaseForeground) | 33 if (paintContext.paintInfo().phase == PaintPhaseForeground) |
| 54 continueRendering = paintContext.applyClipMaskAndFilterIfNecessary(); | 34 continueRendering = paintContext.applyClipMaskAndFilterIfNecessary(); |
| 55 | 35 |
| 56 if (continueRendering) { | 36 if (continueRendering) { |
| 57 // Paint all phases of FO elements atomically as though the FO element e
stablished its own stacking context. | 37 // Paint all phases of FO elements atomically as though the FO element e
stablished its own stacking context. |
| 58 // The delegate forwards calls to paint() in LayoutObject::paintAsPseudo
StackingContext() to | 38 bool preservePhase = paintContext.paintInfo().phase == PaintPhaseSelecti
on || paintContext.paintInfo().phase == PaintPhaseTextClip; |
| 59 // BlockPainter::paint(), instead of m_layoutSVGForeignObject.paint() (w
hich would call this method again). | 39 const LayoutPoint childPoint = IntPoint(); |
| 60 BlockPainterDelegate delegate(m_layoutSVGForeignObject); | 40 paintContext.paintInfo().phase = preservePhase ? paintContext.paintInfo(
).phase : PaintPhaseBlockBackground; |
| 61 ObjectPainter(delegate).paintAsPseudoStackingContext(paintContext.paintI
nfo(), LayoutPoint()); | 41 BlockPainter(m_layoutSVGForeignObject).paint(paintContext.paintInfo(), c
hildPoint); |
| 42 if (!preservePhase) { |
| 43 paintContext.paintInfo().phase = PaintPhaseChildBlockBackgrounds; |
| 44 BlockPainter(m_layoutSVGForeignObject).paint(paintContext.paintInfo(
), childPoint); |
| 45 paintContext.paintInfo().phase = PaintPhaseFloat; |
| 46 BlockPainter(m_layoutSVGForeignObject).paint(paintContext.paintInfo(
), childPoint); |
| 47 paintContext.paintInfo().phase = PaintPhaseForeground; |
| 48 BlockPainter(m_layoutSVGForeignObject).paint(paintContext.paintInfo(
), childPoint); |
| 49 paintContext.paintInfo().phase = PaintPhaseOutline; |
| 50 BlockPainter(m_layoutSVGForeignObject).paint(paintContext.paintInfo(
), childPoint); |
| 51 } |
| 62 } | 52 } |
| 63 } | 53 } |
| 64 | 54 |
| 65 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |