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