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

Side by Side Diff: Source/core/layout/svg/LayoutSVGRoot.cpp

Issue 933953003: Move the remaining rendering/svg/RenderSVG* files to layout. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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/layout/svg/LayoutSVGRoot.h ('k') | Source/core/layout/svg/LayoutSVGShape.h » ('j') | 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) 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, 2008, 2009 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 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 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 */ 22 */
23 23
24 #include "config.h" 24 #include "config.h"
25 25
26 #include "core/rendering/svg/RenderSVGRoot.h" 26 #include "core/layout/svg/LayoutSVGRoot.h"
27 27
28 #include "core/frame/LocalFrame.h" 28 #include "core/frame/LocalFrame.h"
29 #include "core/layout/HitTestResult.h" 29 #include "core/layout/HitTestResult.h"
30 #include "core/layout/Layer.h" 30 #include "core/layout/Layer.h"
31 #include "core/layout/LayoutPart.h" 31 #include "core/layout/LayoutPart.h"
32 #include "core/layout/svg/SVGLayoutSupport.h" 32 #include "core/layout/svg/SVGLayoutSupport.h"
33 #include "core/layout/svg/SVGResourcesCache.h" 33 #include "core/layout/svg/SVGResourcesCache.h"
34 #include "core/paint/SVGRootPainter.h" 34 #include "core/paint/SVGRootPainter.h"
35 #include "core/rendering/RenderView.h" 35 #include "core/rendering/RenderView.h"
36 #include "core/svg/SVGElement.h" 36 #include "core/svg/SVGElement.h"
37 #include "core/svg/SVGSVGElement.h" 37 #include "core/svg/SVGSVGElement.h"
38 #include "core/svg/graphics/SVGImage.h" 38 #include "core/svg/graphics/SVGImage.h"
39 #include "platform/LengthFunctions.h" 39 #include "platform/LengthFunctions.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 RenderSVGRoot::RenderSVGRoot(SVGElement* node) 43 LayoutSVGRoot::LayoutSVGRoot(SVGElement* node)
44 : LayoutReplaced(node) 44 : LayoutReplaced(node)
45 , m_objectBoundingBoxValid(false) 45 , m_objectBoundingBoxValid(false)
46 , m_isLayoutSizeChanged(false) 46 , m_isLayoutSizeChanged(false)
47 , m_needsBoundariesOrTransformUpdate(true) 47 , m_needsBoundariesOrTransformUpdate(true)
48 , m_hasBoxDecorationBackground(false) 48 , m_hasBoxDecorationBackground(false)
49 , m_hasNonIsolatedBlendingDescendants(false) 49 , m_hasNonIsolatedBlendingDescendants(false)
50 , m_hasNonIsolatedBlendingDescendantsDirty(false) 50 , m_hasNonIsolatedBlendingDescendantsDirty(false)
51 { 51 {
52 } 52 }
53 53
54 RenderSVGRoot::~RenderSVGRoot() 54 LayoutSVGRoot::~LayoutSVGRoot()
55 { 55 {
56 } 56 }
57 57
58 void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, d ouble& intrinsicRatio) const 58 void LayoutSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, d ouble& intrinsicRatio) const
59 { 59 {
60 // Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing 60 // Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
61 // SVG needs to specify how to calculate some intrinsic sizing properties to enable inclusion within other languages. 61 // SVG needs to specify how to calculate some intrinsic sizing properties to enable inclusion within other languages.
62 // The intrinsic width and height of the viewport of SVG content must be det ermined from the 'width' and 'height' attributes. 62 // The intrinsic width and height of the viewport of SVG content must be det ermined from the 'width' and 'height' attributes.
63 SVGSVGElement* svg = toSVGSVGElement(node()); 63 SVGSVGElement* svg = toSVGSVGElement(node());
64 ASSERT(svg); 64 ASSERT(svg);
65 65
66 // The intrinsic aspect ratio of the viewport of SVG content is necessary fo r example, when including SVG from an 'object' 66 // The intrinsic aspect ratio of the viewport of SVG content is necessary fo r example, when including SVG from an 'object'
67 // element in HTML styled with CSS. It is possible (indeed, common) for an S VG graphic to have an intrinsic aspect ratio but 67 // element in HTML styled with CSS. It is possible (indeed, common) for an S VG graphic to have an intrinsic aspect ratio but
68 // not to have an intrinsic width or height. The intrinsic aspect ratio must be calculated based upon the following rules: 68 // not to have an intrinsic width or height. The intrinsic aspect ratio must be calculated based upon the following rules:
(...skipping 12 matching lines...) Expand all
81 // fragment. If the 'viewBox' is not correctly specified, or set to 'n one', the intrinsic aspect ratio cannot be 81 // fragment. If the 'viewBox' is not correctly specified, or set to 'n one', the intrinsic aspect ratio cannot be
82 // calculated and is considered unspecified. 82 // calculated and is considered unspecified.
83 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size(); 83 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size();
84 if (!viewBoxSize.isEmpty()) { 84 if (!viewBoxSize.isEmpty()) {
85 // The viewBox can only yield an intrinsic ratio, not an intrinsic s ize. 85 // The viewBox can only yield an intrinsic ratio, not an intrinsic s ize.
86 intrinsicRatio = viewBoxSize.width() / static_cast<double>(viewBoxSi ze.height()); 86 intrinsicRatio = viewBoxSize.width() / static_cast<double>(viewBoxSi ze.height());
87 } 87 }
88 } 88 }
89 } 89 }
90 90
91 bool RenderSVGRoot::isEmbeddedThroughSVGImage() const 91 bool LayoutSVGRoot::isEmbeddedThroughSVGImage() const
92 { 92 {
93 return SVGImage::isInSVGImage(toSVGSVGElement(node())); 93 return SVGImage::isInSVGImage(toSVGSVGElement(node()));
94 } 94 }
95 95
96 bool RenderSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const 96 bool LayoutSVGRoot::isEmbeddedThroughFrameContainingSVGDocument() const
97 { 97 {
98 if (!node()) 98 if (!node())
99 return false; 99 return false;
100 100
101 LocalFrame* frame = node()->document().frame(); 101 LocalFrame* frame = node()->document().frame();
102 if (!frame) 102 if (!frame)
103 return false; 103 return false;
104 104
105 // If our frame has an owner renderer, we're embedded through eg. object/emb ed/iframe, 105 // If our frame has an owner renderer, we're embedded through eg. object/emb ed/iframe,
106 // but we only negotiate if we're in an SVG document inside a embedded objec t (object/embed). 106 // but we only negotiate if we're in an SVG document inside a embedded objec t (object/embed).
107 if (!frame->ownerRenderer() || !frame->ownerRenderer()->isEmbeddedObject()) 107 if (!frame->ownerRenderer() || !frame->ownerRenderer()->isEmbeddedObject())
108 return false; 108 return false;
109 return frame->document()->isSVGDocument(); 109 return frame->document()->isSVGDocument();
110 } 110 }
111 111
112 static inline LayoutUnit resolveLengthAttributeForSVG(const Length& length, floa t scale, float maxSize) 112 static inline LayoutUnit resolveLengthAttributeForSVG(const Length& length, floa t scale, float maxSize)
113 { 113 {
114 return static_cast<LayoutUnit>(valueForLength(length, maxSize) * (length.isF ixed() ? scale : 1)); 114 return static_cast<LayoutUnit>(valueForLength(length, maxSize) * (length.isF ixed() ? scale : 1));
115 } 115 }
116 116
117 LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred sho uldComputePreferred) const 117 LayoutUnit LayoutSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred sho uldComputePreferred) const
118 { 118 {
119 SVGSVGElement* svg = toSVGSVGElement(node()); 119 SVGSVGElement* svg = toSVGSVGElement(node());
120 ASSERT(svg); 120 ASSERT(svg);
121 121
122 // When we're embedded through SVGImage (border-image/background-image/<html :img>/...) we're forced to resize to a specific size. 122 // When we're embedded through SVGImage (border-image/background-image/<html :img>/...) we're forced to resize to a specific size.
123 if (!m_containerSize.isEmpty()) 123 if (!m_containerSize.isEmpty())
124 return m_containerSize.width(); 124 return m_containerSize.width();
125 125
126 if (isEmbeddedThroughFrameContainingSVGDocument()) 126 if (isEmbeddedThroughFrameContainingSVGDocument())
127 return containingBlock()->availableLogicalWidth(); 127 return containingBlock()->availableLogicalWidth();
128 128
129 if (style()->logicalWidth().isSpecified() || style()->logicalMaxWidth().isSp ecified()) 129 if (style()->logicalWidth().isSpecified() || style()->logicalMaxWidth().isSp ecified())
130 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferre d); 130 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferre d);
131 131
132 if (svg->hasIntrinsicWidth()) 132 if (svg->hasIntrinsicWidth())
133 return resolveLengthAttributeForSVG(svg->intrinsicWidth(), style()->effe ctiveZoom(), containingBlock()->availableLogicalWidth().toFloat()); 133 return resolveLengthAttributeForSVG(svg->intrinsicWidth(), style()->effe ctiveZoom(), containingBlock()->availableLogicalWidth().toFloat());
134 134
135 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV G. 135 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV G.
136 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferred); 136 return LayoutReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
137 } 137 }
138 138
139 LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const 139 LayoutUnit LayoutSVGRoot::computeReplacedLogicalHeight() const
140 { 140 {
141 SVGSVGElement* svg = toSVGSVGElement(node()); 141 SVGSVGElement* svg = toSVGSVGElement(node());
142 ASSERT(svg); 142 ASSERT(svg);
143 143
144 // When we're embedded through SVGImage (border-image/background-image/<html :img>/...) we're forced to resize to a specific size. 144 // When we're embedded through SVGImage (border-image/background-image/<html :img>/...) we're forced to resize to a specific size.
145 if (!m_containerSize.isEmpty()) 145 if (!m_containerSize.isEmpty())
146 return m_containerSize.height(); 146 return m_containerSize.height();
147 147
148 if (isEmbeddedThroughFrameContainingSVGDocument()) 148 if (isEmbeddedThroughFrameContainingSVGDocument())
149 return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadd ing); 149 return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadd ing);
150 150
151 if (style()->logicalHeight().isSpecified() || style()->logicalMaxHeight().is Specified()) 151 if (style()->logicalHeight().isSpecified() || style()->logicalMaxHeight().is Specified())
152 return LayoutReplaced::computeReplacedLogicalHeight(); 152 return LayoutReplaced::computeReplacedLogicalHeight();
153 153
154 if (svg->hasIntrinsicHeight()) 154 if (svg->hasIntrinsicHeight())
155 return resolveLengthAttributeForSVG(svg->intrinsicHeight(), style()->eff ectiveZoom(), containingBlock()->availableLogicalHeight(IncludeMarginBorderPaddi ng).toFloat()); 155 return resolveLengthAttributeForSVG(svg->intrinsicHeight(), style()->eff ectiveZoom(), containingBlock()->availableLogicalHeight(IncludeMarginBorderPaddi ng).toFloat());
156 156
157 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV G. 157 // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SV G.
158 return LayoutReplaced::computeReplacedLogicalHeight(); 158 return LayoutReplaced::computeReplacedLogicalHeight();
159 } 159 }
160 160
161 void RenderSVGRoot::layout() 161 void LayoutSVGRoot::layout()
162 { 162 {
163 ASSERT(needsLayout()); 163 ASSERT(needsLayout());
164 164
165 bool needsLayout = selfNeedsLayout(); 165 bool needsLayout = selfNeedsLayout();
166 166
167 LayoutSize oldSize = size(); 167 LayoutSize oldSize = size();
168 updateLogicalWidth(); 168 updateLogicalWidth();
169 updateLogicalHeight(); 169 updateLogicalHeight();
170 buildLocalToBorderBoxTransform(); 170 buildLocalToBorderBoxTransform();
171 171
(...skipping 18 matching lines...) Expand all
190 addVisualOverflow(enclosingLayoutRect(contentPaintInvalidationRect)); 190 addVisualOverflow(enclosingLayoutRect(contentPaintInvalidationRect));
191 } 191 }
192 192
193 updateLayerTransformAfterLayout(); 193 updateLayerTransformAfterLayout();
194 m_hasBoxDecorationBackground = isDocumentElement() ? calculateHasBoxDecorati ons() : hasBoxDecorationBackground(); 194 m_hasBoxDecorationBackground = isDocumentElement() ? calculateHasBoxDecorati ons() : hasBoxDecorationBackground();
195 invalidateBackgroundObscurationStatus(); 195 invalidateBackgroundObscurationStatus();
196 196
197 clearNeedsLayout(); 197 clearNeedsLayout();
198 } 198 }
199 199
200 bool RenderSVGRoot::shouldApplyViewportClip() const 200 bool LayoutSVGRoot::shouldApplyViewportClip() const
201 { 201 {
202 // the outermost svg is clipped if auto, and svg document roots are always c lipped 202 // the outermost svg is clipped if auto, and svg document roots are always c lipped
203 // When the svg is stand-alone (isDocumentElement() == true) the viewport cl ipping should always 203 // When the svg is stand-alone (isDocumentElement() == true) the viewport cl ipping should always
204 // be applied, noting that the window scrollbars should be hidden if overflo w=hidden. 204 // be applied, noting that the window scrollbars should be hidden if overflo w=hidden.
205 return style()->overflowX() == OHIDDEN 205 return style()->overflowX() == OHIDDEN
206 || style()->overflowX() == OAUTO 206 || style()->overflowX() == OAUTO
207 || style()->overflowX() == OSCROLL 207 || style()->overflowX() == OSCROLL
208 || this->isDocumentElement(); 208 || this->isDocumentElement();
209 } 209 }
210 210
211 void RenderSVGRoot::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 211 void LayoutSVGRoot::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
212 { 212 {
213 SVGRootPainter(*this).paint(paintInfo, paintOffset); 213 SVGRootPainter(*this).paint(paintInfo, paintOffset);
214 } 214 }
215 215
216 void RenderSVGRoot::willBeDestroyed() 216 void LayoutSVGRoot::willBeDestroyed()
217 { 217 {
218 RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot*>(this)) ; 218 RenderBlock::removePercentHeightDescendant(const_cast<LayoutSVGRoot*>(this)) ;
219 219
220 SVGResourcesCache::clientDestroyed(this); 220 SVGResourcesCache::clientDestroyed(this);
221 LayoutReplaced::willBeDestroyed(); 221 LayoutReplaced::willBeDestroyed();
222 } 222 }
223 223
224 void RenderSVGRoot::styleDidChange(StyleDifference diff, const LayoutStyle* oldS tyle) 224 void LayoutSVGRoot::styleDidChange(StyleDifference diff, const LayoutStyle* oldS tyle)
225 { 225 {
226 if (diff.needsFullLayout()) 226 if (diff.needsFullLayout())
227 setNeedsBoundariesUpdate(); 227 setNeedsBoundariesUpdate();
228 if (diff.needsPaintInvalidation()) { 228 if (diff.needsPaintInvalidation()) {
229 // Box decorations may have appeared/disappeared - recompute status. 229 // Box decorations may have appeared/disappeared - recompute status.
230 m_hasBoxDecorationBackground = calculateHasBoxDecorations(); 230 m_hasBoxDecorationBackground = calculateHasBoxDecorations();
231 } 231 }
232 232
233 LayoutReplaced::styleDidChange(diff, oldStyle); 233 LayoutReplaced::styleDidChange(diff, oldStyle);
234 SVGResourcesCache::clientStyleChanged(this, diff, styleRef()); 234 SVGResourcesCache::clientStyleChanged(this, diff, styleRef());
235 } 235 }
236 236
237 bool RenderSVGRoot::isChildAllowed(LayoutObject* child, const LayoutStyle&) cons t 237 bool LayoutSVGRoot::isChildAllowed(LayoutObject* child, const LayoutStyle&) cons t
238 { 238 {
239 return child->isSVG() && !(child->isSVGInline() || child->isSVGInlineText()) ; 239 return child->isSVG() && !(child->isSVGInline() || child->isSVGInlineText()) ;
240 } 240 }
241 241
242 void RenderSVGRoot::addChild(LayoutObject* child, LayoutObject* beforeChild) 242 void LayoutSVGRoot::addChild(LayoutObject* child, LayoutObject* beforeChild)
243 { 243 {
244 LayoutReplaced::addChild(child, beforeChild); 244 LayoutReplaced::addChild(child, beforeChild);
245 SVGResourcesCache::clientWasAddedToTree(child, child->styleRef()); 245 SVGResourcesCache::clientWasAddedToTree(child, child->styleRef());
246 246
247 bool shouldIsolateDescendants = (child->isBlendingAllowed() && child->style( )->hasBlendMode()) || child->hasNonIsolatedBlendingDescendants(); 247 bool shouldIsolateDescendants = (child->isBlendingAllowed() && child->style( )->hasBlendMode()) || child->hasNonIsolatedBlendingDescendants();
248 if (shouldIsolateDescendants) 248 if (shouldIsolateDescendants)
249 descendantIsolationRequirementsChanged(DescendantIsolationRequired); 249 descendantIsolationRequirementsChanged(DescendantIsolationRequired);
250 } 250 }
251 251
252 void RenderSVGRoot::removeChild(LayoutObject* child) 252 void LayoutSVGRoot::removeChild(LayoutObject* child)
253 { 253 {
254 SVGResourcesCache::clientWillBeRemovedFromTree(child); 254 SVGResourcesCache::clientWillBeRemovedFromTree(child);
255 LayoutReplaced::removeChild(child); 255 LayoutReplaced::removeChild(child);
256 256
257 bool hadNonIsolatedDescendants = (child->isBlendingAllowed() && child->style ()->hasBlendMode()) || child->hasNonIsolatedBlendingDescendants(); 257 bool hadNonIsolatedDescendants = (child->isBlendingAllowed() && child->style ()->hasBlendMode()) || child->hasNonIsolatedBlendingDescendants();
258 if (hadNonIsolatedDescendants) 258 if (hadNonIsolatedDescendants)
259 descendantIsolationRequirementsChanged(DescendantIsolationNeedsUpdate); 259 descendantIsolationRequirementsChanged(DescendantIsolationNeedsUpdate);
260 } 260 }
261 261
262 bool RenderSVGRoot::hasNonIsolatedBlendingDescendants() const 262 bool LayoutSVGRoot::hasNonIsolatedBlendingDescendants() const
263 { 263 {
264 if (m_hasNonIsolatedBlendingDescendantsDirty) { 264 if (m_hasNonIsolatedBlendingDescendantsDirty) {
265 m_hasNonIsolatedBlendingDescendants = SVGLayoutSupport::computeHasNonIso latedBlendingDescendants(this); 265 m_hasNonIsolatedBlendingDescendants = SVGLayoutSupport::computeHasNonIso latedBlendingDescendants(this);
266 m_hasNonIsolatedBlendingDescendantsDirty = false; 266 m_hasNonIsolatedBlendingDescendantsDirty = false;
267 } 267 }
268 return m_hasNonIsolatedBlendingDescendants; 268 return m_hasNonIsolatedBlendingDescendants;
269 } 269 }
270 270
271 void RenderSVGRoot::descendantIsolationRequirementsChanged(DescendantIsolationSt ate state) 271 void LayoutSVGRoot::descendantIsolationRequirementsChanged(DescendantIsolationSt ate state)
272 { 272 {
273 switch (state) { 273 switch (state) {
274 case DescendantIsolationRequired: 274 case DescendantIsolationRequired:
275 m_hasNonIsolatedBlendingDescendants = true; 275 m_hasNonIsolatedBlendingDescendants = true;
276 m_hasNonIsolatedBlendingDescendantsDirty = false; 276 m_hasNonIsolatedBlendingDescendantsDirty = false;
277 break; 277 break;
278 case DescendantIsolationNeedsUpdate: 278 case DescendantIsolationNeedsUpdate:
279 m_hasNonIsolatedBlendingDescendantsDirty = true; 279 m_hasNonIsolatedBlendingDescendantsDirty = true;
280 break; 280 break;
281 } 281 }
282 } 282 }
283 283
284 void RenderSVGRoot::insertedIntoTree() 284 void LayoutSVGRoot::insertedIntoTree()
285 { 285 {
286 LayoutReplaced::insertedIntoTree(); 286 LayoutReplaced::insertedIntoTree();
287 SVGResourcesCache::clientWasAddedToTree(this, styleRef()); 287 SVGResourcesCache::clientWasAddedToTree(this, styleRef());
288 } 288 }
289 289
290 void RenderSVGRoot::willBeRemovedFromTree() 290 void LayoutSVGRoot::willBeRemovedFromTree()
291 { 291 {
292 SVGResourcesCache::clientWillBeRemovedFromTree(this); 292 SVGResourcesCache::clientWillBeRemovedFromTree(this);
293 LayoutReplaced::willBeRemovedFromTree(); 293 LayoutReplaced::willBeRemovedFromTree();
294 } 294 }
295 295
296 // RenderBox methods will expect coordinates w/o any transforms in coordinates 296 // RenderBox methods will expect coordinates w/o any transforms in coordinates
297 // relative to our borderBox origin. This method gives us exactly that. 297 // relative to our borderBox origin. This method gives us exactly that.
298 void RenderSVGRoot::buildLocalToBorderBoxTransform() 298 void LayoutSVGRoot::buildLocalToBorderBoxTransform()
299 { 299 {
300 SVGSVGElement* svg = toSVGSVGElement(node()); 300 SVGSVGElement* svg = toSVGSVGElement(node());
301 ASSERT(svg); 301 ASSERT(svg);
302 float scale = style()->effectiveZoom(); 302 float scale = style()->effectiveZoom();
303 FloatPoint translate = svg->currentTranslate(); 303 FloatPoint translate = svg->currentTranslate();
304 LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + padd ingTop()); 304 LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + padd ingTop());
305 m_localToBorderBoxTransform = svg->viewBoxToViewTransform(contentWidth() / s cale, contentHeight() / scale); 305 m_localToBorderBoxTransform = svg->viewBoxToViewTransform(contentWidth() / s cale, contentHeight() / scale);
306 AffineTransform viewToBorderBoxTransform(scale, 0, 0, scale, borderAndPaddin g.width() + translate.x(), borderAndPadding.height() + translate.y()); 306 AffineTransform viewToBorderBoxTransform(scale, 0, 0, scale, borderAndPaddin g.width() + translate.x(), borderAndPadding.height() + translate.y());
307 if (viewToBorderBoxTransform.isIdentity()) 307 if (viewToBorderBoxTransform.isIdentity())
308 return; 308 return;
309 m_localToBorderBoxTransform = viewToBorderBoxTransform * m_localToBorderBoxT ransform; 309 m_localToBorderBoxTransform = viewToBorderBoxTransform * m_localToBorderBoxT ransform;
310 } 310 }
311 311
312 const AffineTransform& RenderSVGRoot::localToParentTransform() const 312 const AffineTransform& LayoutSVGRoot::localToParentTransform() const
313 { 313 {
314 // Slightly optimized version of m_localToParentTransform = AffineTransform: :translation(x(), y()) * m_localToBorderBoxTransform; 314 // Slightly optimized version of m_localToParentTransform = AffineTransform: :translation(x(), y()) * m_localToBorderBoxTransform;
315 m_localToParentTransform = m_localToBorderBoxTransform; 315 m_localToParentTransform = m_localToBorderBoxTransform;
316 if (location().x()) 316 if (location().x())
317 m_localToParentTransform.setE(m_localToParentTransform.e() + roundToInt( location().x())); 317 m_localToParentTransform.setE(m_localToParentTransform.e() + roundToInt( location().x()));
318 if (location().y()) 318 if (location().y())
319 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt( location().y())); 319 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt( location().y()));
320 return m_localToParentTransform; 320 return m_localToParentTransform;
321 } 321 }
322 322
323 LayoutRect RenderSVGRoot::clippedOverflowRectForPaintInvalidation(const LayoutLa yerModelObject* paintInvalidationContainer, const PaintInvalidationState* paintI nvalidationState) const 323 LayoutRect LayoutSVGRoot::clippedOverflowRectForPaintInvalidation(const LayoutLa yerModelObject* paintInvalidationContainer, const PaintInvalidationState* paintI nvalidationState) const
324 { 324 {
325 // This is an open-coded aggregate of SVGLayoutSupport::clippedOverflowRectF orPaintInvalidation, 325 // This is an open-coded aggregate of SVGLayoutSupport::clippedOverflowRectF orPaintInvalidation,
326 // RenderSVGRoot::mapRectToPaintInvalidationBacking and LayoutReplaced::clip pedOverflowRectForPaintInvalidation. 326 // LayoutSVGRoot::mapRectToPaintInvalidationBacking and LayoutReplaced::clip pedOverflowRectForPaintInvalidation.
327 // The reason for this is to optimize/minimize the paint invalidation rect w hen the box is not "decorated" 327 // The reason for this is to optimize/minimize the paint invalidation rect w hen the box is not "decorated"
328 // (does not have background/border/etc.) 328 // (does not have background/border/etc.)
329 329
330 // Return early for any cases where we don't actually paint. 330 // Return early for any cases where we don't actually paint.
331 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ()) 331 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ())
332 return LayoutRect(); 332 return LayoutRect();
333 333
334 // Compute the paint invalidation rect of the content of the SVG in the bord er-box coordinate space. 334 // Compute the paint invalidation rect of the content of the SVG in the bord er-box coordinate space.
335 FloatRect contentPaintInvalidationRect = paintInvalidationRectInLocalCoordin ates(); 335 FloatRect contentPaintInvalidationRect = paintInvalidationRectInLocalCoordin ates();
336 contentPaintInvalidationRect = m_localToBorderBoxTransform.mapRect(contentPa intInvalidationRect); 336 contentPaintInvalidationRect = m_localToBorderBoxTransform.mapRect(contentPa intInvalidationRect);
(...skipping 10 matching lines...) Expand all
347 LayoutRect decoratedPaintInvalidationRect = unionRect(localSelectionRect (false), visualOverflowRect()); 347 LayoutRect decoratedPaintInvalidationRect = unionRect(localSelectionRect (false), visualOverflowRect());
348 paintInvalidationRect.unite(decoratedPaintInvalidationRect); 348 paintInvalidationRect.unite(decoratedPaintInvalidationRect);
349 } 349 }
350 350
351 // Compute the paint invalidation rect in the parent coordinate space. 351 // Compute the paint invalidation rect in the parent coordinate space.
352 LayoutRect rect = enclosingIntRect(paintInvalidationRect); 352 LayoutRect rect = enclosingIntRect(paintInvalidationRect);
353 LayoutReplaced::mapRectToPaintInvalidationBacking(paintInvalidationContainer , rect, paintInvalidationState); 353 LayoutReplaced::mapRectToPaintInvalidationBacking(paintInvalidationContainer , rect, paintInvalidationState);
354 return rect; 354 return rect;
355 } 355 }
356 356
357 void RenderSVGRoot::mapRectToPaintInvalidationBacking(const LayoutLayerModelObje ct* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintInvalidationState) const 357 void LayoutSVGRoot::mapRectToPaintInvalidationBacking(const LayoutLayerModelObje ct* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintInvalidationState) const
358 { 358 {
359 // Note that we don't apply the border-box transform here - it's assumed 359 // Note that we don't apply the border-box transform here - it's assumed
360 // that whoever called us has done that already. 360 // that whoever called us has done that already.
361 361
362 // Apply initial viewport clip 362 // Apply initial viewport clip
363 if (shouldApplyViewportClip()) 363 if (shouldApplyViewportClip())
364 rect.intersect(pixelSnappedBorderBoxRect()); 364 rect.intersect(pixelSnappedBorderBoxRect());
365 365
366 LayoutReplaced::mapRectToPaintInvalidationBacking(paintInvalidationContainer , rect, paintInvalidationState); 366 LayoutReplaced::mapRectToPaintInvalidationBacking(paintInvalidationContainer , rect, paintInvalidationState);
367 } 367 }
368 368
369 // This method expects local CSS box coordinates. 369 // This method expects local CSS box coordinates.
370 // Callers with local SVG viewport coordinates should first apply the localToBor derBoxTransform 370 // Callers with local SVG viewport coordinates should first apply the localToBor derBoxTransform
371 // to convert from SVG viewport coordinates to local CSS box coordinates. 371 // to convert from SVG viewport coordinates to local CSS box coordinates.
372 void RenderSVGRoot::mapLocalToContainer(const LayoutLayerModelObject* paintInval idationContainer, TransformState& transformState, MapCoordinatesFlags mode, bool * wasFixed, const PaintInvalidationState* paintInvalidationState) const 372 void LayoutSVGRoot::mapLocalToContainer(const LayoutLayerModelObject* paintInval idationContainer, TransformState& transformState, MapCoordinatesFlags mode, bool * wasFixed, const PaintInvalidationState* paintInvalidationState) const
373 { 373 {
374 ASSERT(mode & ~IsFixed); // We should have no fixed content in the SVG rende ring tree. 374 ASSERT(mode & ~IsFixed); // We should have no fixed content in the SVG rende ring tree.
375 // We used to have this ASSERT here, but we removed it when enabling layer s quashing. 375 // We used to have this ASSERT here, but we removed it when enabling layer s quashing.
376 // See http://crbug.com/364901 376 // See http://crbug.com/364901
377 // ASSERT(mode & UseTransforms); // mapping a point through SVG w/o respecti ng trasnforms is useless. 377 // ASSERT(mode & UseTransforms); // mapping a point through SVG w/o respecti ng trasnforms is useless.
378 378
379 LayoutReplaced::mapLocalToContainer(paintInvalidationContainer, transformSta te, mode | ApplyContainerFlip, wasFixed, paintInvalidationState); 379 LayoutReplaced::mapLocalToContainer(paintInvalidationContainer, transformSta te, mode | ApplyContainerFlip, wasFixed, paintInvalidationState);
380 } 380 }
381 381
382 const LayoutObject* RenderSVGRoot::pushMappingToContainer(const LayoutLayerModel Object* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 382 const LayoutObject* LayoutSVGRoot::pushMappingToContainer(const LayoutLayerModel Object* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
383 { 383 {
384 return LayoutReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap) ; 384 return LayoutReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap) ;
385 } 385 }
386 386
387 void RenderSVGRoot::updateCachedBoundaries() 387 void LayoutSVGRoot::updateCachedBoundaries()
388 { 388 {
389 SVGLayoutSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m _objectBoundingBoxValid, m_strokeBoundingBox, m_paintInvalidationBoundingBox); 389 SVGLayoutSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m _objectBoundingBoxValid, m_strokeBoundingBox, m_paintInvalidationBoundingBox);
390 SVGLayoutSupport::intersectPaintInvalidationRectWithResources(this, m_paintI nvalidationBoundingBox); 390 SVGLayoutSupport::intersectPaintInvalidationRectWithResources(this, m_paintI nvalidationBoundingBox);
391 } 391 }
392 392
393 bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction) 393 bool LayoutSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction)
394 { 394 {
395 LayoutPoint pointInParent = locationInContainer.point() - toLayoutSize(accum ulatedOffset); 395 LayoutPoint pointInParent = locationInContainer.point() - toLayoutSize(accum ulatedOffset);
396 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location()); 396 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location());
397 397
398 // Only test SVG content if the point is in our content box, or in case we 398 // Only test SVG content if the point is in our content box, or in case we
399 // don't clip to the viewport, the visual overflow rect. 399 // don't clip to the viewport, the visual overflow rect.
400 // FIXME: This should be an intersection when rect-based hit tests are suppo rted by nodeAtFloatPoint. 400 // FIXME: This should be an intersection when rect-based hit tests are suppo rted by nodeAtFloatPoint.
401 if (contentBoxRect().contains(pointInBorderBox) || (!shouldApplyViewportClip () && visualOverflowRect().contains(pointInBorderBox))) { 401 if (contentBoxRect().contains(pointInBorderBox) || (!shouldApplyViewportClip () && visualOverflowRect().contains(pointInBorderBox))) {
402 const AffineTransform& localToParentTransform = this->localToParentTrans form(); 402 const AffineTransform& localToParentTransform = this->localToParentTrans form();
403 if (localToParentTransform.isInvertible()) { 403 if (localToParentTransform.isInvertible()) {
(...skipping 21 matching lines...) Expand all
425 updateHitTestResult(result, pointInBorderBox); 425 updateHitTestResult(result, pointInBorderBox);
426 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn Container, boundsRect)) 426 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn Container, boundsRect))
427 return true; 427 return true;
428 } 428 }
429 } 429 }
430 430
431 return false; 431 return false;
432 } 432 }
433 433
434 } 434 }
OLDNEW
« no previous file with comments | « Source/core/layout/svg/LayoutSVGRoot.h ('k') | Source/core/layout/svg/LayoutSVGShape.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698