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

Side by Side Diff: Source/core/rendering/svg/RenderSVGForeignObject.cpp

Issue 597753002: Move paint code from RenderSVGForeignObject to SVGForeignObjectPainter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add SVGForeignObjectPainter Created 6 years, 3 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
« no previous file with comments | « Source/core/rendering/svg/RenderSVGForeignObject.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. 2 * Copyright (C) 2006 Apple Computer, Inc.
3 * Copyright (C) 2009 Google, Inc. 3 * Copyright (C) 2009 Google, Inc.
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 */ 20 */
21 21
22 #include "config.h" 22 #include "config.h"
23 23
24 #include "core/rendering/svg/RenderSVGForeignObject.h" 24 #include "core/rendering/svg/RenderSVGForeignObject.h"
25 25
26 #include "core/paint/SVGForeignObjectPainter.h"
26 #include "core/rendering/HitTestResult.h" 27 #include "core/rendering/HitTestResult.h"
27 #include "core/rendering/RenderView.h" 28 #include "core/rendering/RenderView.h"
28 #include "core/rendering/svg/SVGRenderSupport.h" 29 #include "core/rendering/svg/SVGRenderSupport.h"
29 #include "core/rendering/svg/SVGRenderingContext.h"
30 #include "core/rendering/svg/SVGResourcesCache.h" 30 #include "core/rendering/svg/SVGResourcesCache.h"
31 #include "core/svg/SVGForeignObjectElement.h" 31 #include "core/svg/SVGForeignObjectElement.h"
32 #include "platform/graphics/GraphicsContextStateSaver.h"
33 32
34 namespace blink { 33 namespace blink {
35 34
36 RenderSVGForeignObject::RenderSVGForeignObject(SVGForeignObjectElement* node) 35 RenderSVGForeignObject::RenderSVGForeignObject(SVGForeignObjectElement* node)
37 : RenderSVGBlock(node) 36 : RenderSVGBlock(node)
38 , m_needsTransformUpdate(true) 37 , m_needsTransformUpdate(true)
39 { 38 {
40 } 39 }
41 40
42 RenderSVGForeignObject::~RenderSVGForeignObject() 41 RenderSVGForeignObject::~RenderSVGForeignObject()
43 { 42 {
44 } 43 }
45 44
46 bool RenderSVGForeignObject::isChildAllowed(RenderObject* child, RenderStyle* st yle) const 45 bool RenderSVGForeignObject::isChildAllowed(RenderObject* child, RenderStyle* st yle) const
47 { 46 {
48 // Disallow arbitary SVG content. Only allow proper <svg xmlns="svgNS"> subd ocuments. 47 // Disallow arbitary SVG content. Only allow proper <svg xmlns="svgNS"> subd ocuments.
49 return !child->isSVG() || child->isSVGRoot(); 48 return !child->isSVG() || child->isSVGRoot();
50 } 49 }
51 50
52 void RenderSVGForeignObject::paint(PaintInfo& paintInfo, const LayoutPoint&) 51 void RenderSVGForeignObject::paint(PaintInfo& paintInfo, const LayoutPoint&)
53 { 52 {
54 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase Selection) 53 SVGForeignObjectPainter(*this).paint(paintInfo);
55 return;
56
57 PaintInfo childPaintInfo(paintInfo);
58 GraphicsContextStateSaver stateSaver(*childPaintInfo.context);
59 childPaintInfo.applyTransform(localTransform());
60
61 if (SVGRenderSupport::isOverflowHidden(this))
62 childPaintInfo.context->clip(m_viewport);
63
64 SVGRenderingContext renderingContext;
65 bool continueRendering = true;
66 if (paintInfo.phase == PaintPhaseForeground) {
67 renderingContext.prepareToRenderSVGContent(this, childPaintInfo);
68 continueRendering = renderingContext.isRenderingPrepared();
69 }
70
71 if (continueRendering) {
72 // Paint all phases of FO elements atomically, as though the FO element established its
73 // own stacking context.
74 bool preservePhase = paintInfo.phase == PaintPhaseSelection || paintInfo .phase == PaintPhaseTextClip;
75 LayoutPoint childPoint = IntPoint();
76 childPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhaseBlock Background;
77 RenderBlock::paint(childPaintInfo, IntPoint());
78 if (!preservePhase) {
79 childPaintInfo.phase = PaintPhaseChildBlockBackgrounds;
80 RenderBlock::paint(childPaintInfo, childPoint);
81 childPaintInfo.phase = PaintPhaseFloat;
82 RenderBlock::paint(childPaintInfo, childPoint);
83 childPaintInfo.phase = PaintPhaseForeground;
84 RenderBlock::paint(childPaintInfo, childPoint);
85 childPaintInfo.phase = PaintPhaseOutline;
86 RenderBlock::paint(childPaintInfo, childPoint);
87 }
88 }
89 } 54 }
90 55
91 const AffineTransform& RenderSVGForeignObject::localToParentTransform() const 56 const AffineTransform& RenderSVGForeignObject::localToParentTransform() const
92 { 57 {
93 m_localToParentTransform = localTransform(); 58 m_localToParentTransform = localTransform();
94 m_localToParentTransform.translate(m_viewport.x(), m_viewport.y()); 59 m_localToParentTransform.translate(m_viewport.x(), m_viewport.y());
95 return m_localToParentTransform; 60 return m_localToParentTransform;
96 } 61 }
97 62
98 void RenderSVGForeignObject::updateLogicalWidth() 63 void RenderSVGForeignObject::updateLogicalWidth()
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return false; 142 return false;
178 143
179 // FOs establish a stacking context, so we need to hit-test all layers. 144 // FOs establish a stacking context, so we need to hit-test all layers.
180 HitTestLocation hitTestLocation(roundedLayoutPoint(localPoint)); 145 HitTestLocation hitTestLocation(roundedLayoutPoint(localPoint));
181 return RenderBlock::nodeAtPoint(request, result, hitTestLocation, LayoutPoin t(), HitTestForeground) 146 return RenderBlock::nodeAtPoint(request, result, hitTestLocation, LayoutPoin t(), HitTestForeground)
182 || RenderBlock::nodeAtPoint(request, result, hitTestLocation, LayoutPoin t(), HitTestFloat) 147 || RenderBlock::nodeAtPoint(request, result, hitTestLocation, LayoutPoin t(), HitTestFloat)
183 || RenderBlock::nodeAtPoint(request, result, hitTestLocation, LayoutPoin t(), HitTestChildBlockBackgrounds); 148 || RenderBlock::nodeAtPoint(request, result, hitTestLocation, LayoutPoin t(), HitTestChildBlockBackgrounds);
184 } 149 }
185 150
186 } 151 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGForeignObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698