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

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

Issue 191003007: Use isSVG*Element() helpers more in SVG code (Part 3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 24 matching lines...) Expand all
35 RenderSVGViewportContainer::RenderSVGViewportContainer(SVGElement* node) 35 RenderSVGViewportContainer::RenderSVGViewportContainer(SVGElement* node)
36 : RenderSVGContainer(node) 36 : RenderSVGContainer(node)
37 , m_didTransformToRootUpdate(false) 37 , m_didTransformToRootUpdate(false)
38 , m_isLayoutSizeChanged(false) 38 , m_isLayoutSizeChanged(false)
39 , m_needsTransformUpdate(true) 39 , m_needsTransformUpdate(true)
40 { 40 {
41 } 41 }
42 42
43 void RenderSVGViewportContainer::determineIfLayoutSizeChanged() 43 void RenderSVGViewportContainer::determineIfLayoutSizeChanged()
44 { 44 {
45 if (!element()->hasTagName(SVGNames::svgTag)) 45 ASSERT(element());
46 if (!isSVGSVGElement(*element()))
46 return; 47 return;
47 48
48 m_isLayoutSizeChanged = toSVGSVGElement(element())->hasRelativeLengths() && selfNeedsLayout(); 49 m_isLayoutSizeChanged = toSVGSVGElement(element())->hasRelativeLengths() && selfNeedsLayout();
49 } 50 }
50 51
51 void RenderSVGViewportContainer::applyViewportClip(PaintInfo& paintInfo) 52 void RenderSVGViewportContainer::applyViewportClip(PaintInfo& paintInfo)
52 { 53 {
53 if (SVGRenderSupport::isOverflowHidden(this)) 54 if (SVGRenderSupport::isOverflowHidden(this))
54 paintInfo.context->clip(m_viewport); 55 paintInfo.context->clip(m_viewport);
55 } 56 }
56 57
57 void RenderSVGViewportContainer::calcViewport() 58 void RenderSVGViewportContainer::calcViewport()
58 { 59 {
59 SVGElement* element = this->element(); 60 SVGElement* element = this->element();
60 if (!element->hasTagName(SVGNames::svgTag)) 61 ASSERT(element);
62 if (!isSVGSVGElement(*element))
61 return; 63 return;
62 SVGSVGElement* svg = toSVGSVGElement(element); 64 SVGSVGElement* svg = toSVGSVGElement(element);
63 FloatRect oldViewport = m_viewport; 65 FloatRect oldViewport = m_viewport;
64 66
65 SVGLengthContext lengthContext(element); 67 SVGLengthContext lengthContext(element);
66 m_viewport = FloatRect(svg->x()->currentValue()->value(lengthContext), svg-> y()->currentValue()->value(lengthContext), svg->width()->currentValue()->value(l engthContext), svg->height()->currentValue()->value(lengthContext)); 68 m_viewport = FloatRect(svg->x()->currentValue()->value(lengthContext), svg-> y()->currentValue()->value(lengthContext), svg->width()->currentValue()->value(l engthContext), svg->height()->currentValue()->value(lengthContext));
67 69
68 SVGElement* correspondingElement = svg->correspondingElement(); 70 SVGElement* correspondingElement = svg->correspondingElement();
69 if (correspondingElement && svg->isInShadowTree()) { 71 if (correspondingElement && svg->isInShadowTree()) {
70 const HashSet<SVGElementInstance*>& instances = correspondingElement->in stancesForElement(); 72 const HashSet<SVGElementInstance*>& instances = correspondingElement->in stancesForElement();
71 ASSERT(!instances.isEmpty()); 73 ASSERT(!instances.isEmpty());
72 74
73 SVGUseElement* useElement = 0; 75 SVGUseElement* useElement = 0;
74 const HashSet<SVGElementInstance*>::const_iterator end = instances.end() ; 76 const HashSet<SVGElementInstance*>::const_iterator end = instances.end() ;
75 for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin() ; it != end; ++it) { 77 for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin() ; it != end; ++it) {
76 const SVGElementInstance* instance = (*it); 78 const SVGElementInstance* instance = (*it);
77 ASSERT(instance->correspondingElement()->hasTagName(SVGNames::svgTag ) || instance->correspondingElement()->hasTagName(SVGNames::symbolTag)); 79 ASSERT(isSVGSVGElement(instance->correspondingElement()) || isSVGSym bolElement(instance->correspondingElement()));
78 if (instance->shadowTreeElement() == svg) { 80 if (instance->shadowTreeElement() == svg) {
79 ASSERT(correspondingElement == instance->correspondingElement()) ; 81 ASSERT(correspondingElement == instance->correspondingElement()) ;
80 useElement = instance->directUseElement(); 82 useElement = instance->directUseElement();
81 if (!useElement) 83 if (!useElement)
82 useElement = instance->correspondingUseElement(); 84 useElement = instance->correspondingUseElement();
83 break; 85 break;
84 } 86 }
85 } 87 }
86 88
87 ASSERT(useElement); 89 ASSERT(useElement);
88 bool isSymbolElement = correspondingElement->hasTagName(SVGNames::symbol Tag); 90 bool isSymbolElement = isSVGSymbolElement(*correspondingElement);
89 91
90 // Spec (<use> on <symbol>): This generated 'svg' will always have expli cit values for attributes width and height. 92 // Spec (<use> on <symbol>): This generated 'svg' will always have expli cit values for attributes width and height.
91 // If attributes width and/or height are provided on the 'use' element, then these attributes 93 // If attributes width and/or height are provided on the 'use' element, then these attributes
92 // will be transferred to the generated 'svg'. If attributes width and/o r height are not specified, 94 // will be transferred to the generated 'svg'. If attributes width and/o r height are not specified,
93 // the generated 'svg' element will use values of 100% for these attribu tes. 95 // the generated 'svg' element will use values of 100% for these attribu tes.
94 96
95 // Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these 97 // Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these
96 // values will override the corresponding attributes on the 'svg' in the generated tree. 98 // values will override the corresponding attributes on the 'svg' in the generated tree.
97 99
98 SVGLengthContext lengthContext(element); 100 SVGLengthContext lengthContext(element);
(...skipping 26 matching lines...) Expand all
125 if (!m_needsTransformUpdate) 127 if (!m_needsTransformUpdate)
126 return false; 128 return false;
127 129
128 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi ewport.y()) * viewportTransform(); 130 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi ewport.y()) * viewportTransform();
129 m_needsTransformUpdate = false; 131 m_needsTransformUpdate = false;
130 return true; 132 return true;
131 } 133 }
132 134
133 AffineTransform RenderSVGViewportContainer::viewportTransform() const 135 AffineTransform RenderSVGViewportContainer::viewportTransform() const
134 { 136 {
135 if (element()->hasTagName(SVGNames::svgTag)) { 137 ASSERT(element());
138 if (isSVGSVGElement(*element())) {
136 SVGSVGElement* svg = toSVGSVGElement(element()); 139 SVGSVGElement* svg = toSVGSVGElement(element());
137 return svg->viewBoxToViewTransform(m_viewport.width(), m_viewport.height ()); 140 return svg->viewBoxToViewTransform(m_viewport.width(), m_viewport.height ());
138 } 141 }
139 142
140 return AffineTransform(); 143 return AffineTransform();
141 } 144 }
142 145
143 bool RenderSVGViewportContainer::pointIsInsideViewportClip(const FloatPoint& poi ntInParent) 146 bool RenderSVGViewportContainer::pointIsInsideViewportClip(const FloatPoint& poi ntInParent)
144 { 147 {
145 // Respect the viewport clip (which is in parent coords) 148 // Respect the viewport clip (which is in parent coords)
146 if (!SVGRenderSupport::isOverflowHidden(this)) 149 if (!SVGRenderSupport::isOverflowHidden(this))
147 return true; 150 return true;
148 151
149 return m_viewport.contains(pointInParent); 152 return m_viewport.contains(pointInParent);
150 } 153 }
151 154
152 void RenderSVGViewportContainer::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 155 void RenderSVGViewportContainer::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
153 { 156 {
157 ASSERT(element());
154 // An empty viewBox disables rendering. 158 // An empty viewBox disables rendering.
155 if (element()->hasTagName(SVGNames::svgTag)) { 159 if (isSVGSVGElement(*element()) && toSVGSVGElement(*element()).hasEmptyViewB ox())
156 if (toSVGSVGElement(element())->hasEmptyViewBox()) 160 return;
157 return;
158 }
159 161
160 RenderSVGContainer::paint(paintInfo, paintOffset); 162 RenderSVGContainer::paint(paintInfo, paintOffset);
161 } 163 }
162 164
163 } 165 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGTransformableContainer.cpp ('k') | Source/core/rendering/svg/SVGRenderTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698