Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: Source/core/paint/SVGContainerPainter.cpp

Issue 1129793005: Replace OwnPtr with WTF::Optional for optional recorders. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge with master Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "config.h" 5 #include "config.h"
6 #include "core/paint/SVGContainerPainter.h" 6 #include "core/paint/SVGContainerPainter.h"
7 7
8 #include "core/layout/svg/LayoutSVGContainer.h" 8 #include "core/layout/svg/LayoutSVGContainer.h"
9 #include "core/layout/svg/LayoutSVGViewportContainer.h" 9 #include "core/layout/svg/LayoutSVGViewportContainer.h"
10 #include "core/layout/svg/SVGLayoutSupport.h" 10 #include "core/layout/svg/SVGLayoutSupport.h"
11 #include "core/paint/FloatClipRecorder.h" 11 #include "core/paint/FloatClipRecorder.h"
12 #include "core/paint/ObjectPainter.h" 12 #include "core/paint/ObjectPainter.h"
13 #include "core/paint/PaintInfo.h" 13 #include "core/paint/PaintInfo.h"
14 #include "core/paint/SVGPaintContext.h" 14 #include "core/paint/SVGPaintContext.h"
15 #include "core/paint/TransformRecorder.h" 15 #include "core/paint/TransformRecorder.h"
16 #include "core/svg/SVGSVGElement.h" 16 #include "core/svg/SVGSVGElement.h"
17 #include "wtf/Optional.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 void SVGContainerPainter::paint(const PaintInfo& paintInfo) 21 void SVGContainerPainter::paint(const PaintInfo& paintInfo)
21 { 22 {
22 // Spec: groups w/o children still may render filter content. 23 // Spec: groups w/o children still may render filter content.
23 if (!m_layoutSVGContainer.firstChild() && !m_layoutSVGContainer.selfWillPain t()) 24 if (!m_layoutSVGContainer.firstChild() && !m_layoutSVGContainer.selfWillPain t())
24 return; 25 return;
25 26
26 FloatRect boundingBox = m_layoutSVGContainer.paintInvalidationRectInLocalCoo rdinates(); 27 FloatRect boundingBox = m_layoutSVGContainer.paintInvalidationRectInLocalCoo rdinates();
27 if (!paintInfo.intersectsCullRect(m_layoutSVGContainer.localToParentTransfor m(), boundingBox)) 28 if (!paintInfo.intersectsCullRect(m_layoutSVGContainer.localToParentTransfor m(), boundingBox))
28 return; 29 return;
29 30
30 // Spec: An empty viewBox on the <svg> element disables rendering. 31 // Spec: An empty viewBox on the <svg> element disables rendering.
31 ASSERT(m_layoutSVGContainer.element()); 32 ASSERT(m_layoutSVGContainer.element());
32 if (isSVGSVGElement(*m_layoutSVGContainer.element()) && toSVGSVGElement(*m_l ayoutSVGContainer.element()).hasEmptyViewBox()) 33 if (isSVGSVGElement(*m_layoutSVGContainer.element()) && toSVGSVGElement(*m_l ayoutSVGContainer.element()).hasEmptyViewBox())
33 return; 34 return;
34 35
35 PaintInfo paintInfoBeforeFiltering(paintInfo); 36 PaintInfo paintInfoBeforeFiltering(paintInfo);
36 paintInfoBeforeFiltering.updateCullRectForSVGTransform(m_layoutSVGContainer. localToParentTransform()); 37 paintInfoBeforeFiltering.updateCullRectForSVGTransform(m_layoutSVGContainer. localToParentTransform());
37 TransformRecorder transformRecorder(*paintInfoBeforeFiltering.context, m_lay outSVGContainer, m_layoutSVGContainer.localToParentTransform()); 38 TransformRecorder transformRecorder(*paintInfoBeforeFiltering.context, m_lay outSVGContainer, m_layoutSVGContainer.localToParentTransform());
38 { 39 {
39 OwnPtr<FloatClipRecorder> clipRecorder; 40 Optional<FloatClipRecorder> clipRecorder;
40 if (m_layoutSVGContainer.isSVGViewportContainer() && SVGLayoutSupport::i sOverflowHidden(&m_layoutSVGContainer)) { 41 if (m_layoutSVGContainer.isSVGViewportContainer() && SVGLayoutSupport::i sOverflowHidden(&m_layoutSVGContainer)) {
41 FloatRect viewport = m_layoutSVGContainer.localToParentTransform().i nverse().mapRect(toLayoutSVGViewportContainer(m_layoutSVGContainer).viewport()); 42 FloatRect viewport = m_layoutSVGContainer.localToParentTransform().i nverse().mapRect(toLayoutSVGViewportContainer(m_layoutSVGContainer).viewport());
42 clipRecorder = adoptPtr(new FloatClipRecorder(*paintInfoBeforeFilter ing.context, m_layoutSVGContainer, paintInfoBeforeFiltering.phase, viewport)); 43 clipRecorder.emplace(*paintInfoBeforeFiltering.context, m_layoutSVGC ontainer, paintInfoBeforeFiltering.phase, viewport);
43 } 44 }
44 45
45 SVGPaintContext paintContext(m_layoutSVGContainer, paintInfoBeforeFilter ing); 46 SVGPaintContext paintContext(m_layoutSVGContainer, paintInfoBeforeFilter ing);
46 bool continueRendering = true; 47 bool continueRendering = true;
47 if (paintContext.paintInfo().phase == PaintPhaseForeground) 48 if (paintContext.paintInfo().phase == PaintPhaseForeground)
48 continueRendering = paintContext.applyClipMaskAndFilterIfNecessary() ; 49 continueRendering = paintContext.applyClipMaskAndFilterIfNecessary() ;
49 50
50 if (continueRendering) { 51 if (continueRendering) {
51 paintContext.paintInfo().updatePaintingRootForChildren(&m_layoutSVGC ontainer); 52 paintContext.paintInfo().updatePaintingRootForChildren(&m_layoutSVGC ontainer);
52 for (LayoutObject* child = m_layoutSVGContainer.firstChild(); child; child = child->nextSibling()) 53 for (LayoutObject* child = m_layoutSVGContainer.firstChild(); child; child = child->nextSibling())
53 child->paint(paintContext.paintInfo(), IntPoint()); 54 child->paint(paintContext.paintInfo(), IntPoint());
54 } 55 }
55 } 56 }
56 57
57 if (paintInfoBeforeFiltering.phase == PaintPhaseForeground && m_layoutSVGCon tainer.style()->outlineWidth() && m_layoutSVGContainer.style()->visibility() == VISIBLE) { 58 if (paintInfoBeforeFiltering.phase == PaintPhaseForeground && m_layoutSVGCon tainer.style()->outlineWidth() && m_layoutSVGContainer.style()->visibility() == VISIBLE) {
58 LayoutRect layoutBoundingBox(boundingBox); 59 LayoutRect layoutBoundingBox(boundingBox);
59 ObjectPainter(m_layoutSVGContainer).paintOutline(paintInfoBeforeFilterin g, layoutBoundingBox, layoutBoundingBox); 60 ObjectPainter(m_layoutSVGContainer).paintOutline(paintInfoBeforeFilterin g, layoutBoundingBox, layoutBoundingBox);
60 } 61 }
61 } 62 }
62 63
63 } // namespace blink 64 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698