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

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

Issue 2748103015: Replace ASSERT with DCHECK in core/layout/<sub dirs> (Closed)
Patch Set: Rebase with latest Created 3 years, 8 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
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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 LayoutSVGRoot::LayoutSVGRoot(SVGElement* node) 42 LayoutSVGRoot::LayoutSVGRoot(SVGElement* node)
43 : LayoutReplaced(node), 43 : LayoutReplaced(node),
44 m_objectBoundingBoxValid(false), 44 m_objectBoundingBoxValid(false),
45 m_isLayoutSizeChanged(false), 45 m_isLayoutSizeChanged(false),
46 m_didScreenScaleFactorChange(false), 46 m_didScreenScaleFactorChange(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 SVGSVGElement* svg = toSVGSVGElement(node); 51 SVGSVGElement* svg = toSVGSVGElement(node);
52 ASSERT(svg); 52 DCHECK(svg);
53 53
54 LayoutSize intrinsicSize(svg->intrinsicWidth(), svg->intrinsicHeight()); 54 LayoutSize intrinsicSize(svg->intrinsicWidth(), svg->intrinsicHeight());
55 if (!svg->hasIntrinsicWidth()) 55 if (!svg->hasIntrinsicWidth())
56 intrinsicSize.setWidth(LayoutUnit(defaultWidth)); 56 intrinsicSize.setWidth(LayoutUnit(defaultWidth));
57 if (!svg->hasIntrinsicHeight()) 57 if (!svg->hasIntrinsicHeight())
58 intrinsicSize.setHeight(LayoutUnit(defaultHeight)); 58 intrinsicSize.setHeight(LayoutUnit(defaultHeight));
59 setIntrinsicSize(intrinsicSize); 59 setIntrinsicSize(intrinsicSize);
60 } 60 }
61 61
62 LayoutSVGRoot::~LayoutSVGRoot() {} 62 LayoutSVGRoot::~LayoutSVGRoot() {}
63 63
64 void LayoutSVGRoot::computeIntrinsicSizingInfo( 64 void LayoutSVGRoot::computeIntrinsicSizingInfo(
65 IntrinsicSizingInfo& intrinsicSizingInfo) const { 65 IntrinsicSizingInfo& intrinsicSizingInfo) const {
66 // https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing 66 // https://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
67 67
68 SVGSVGElement* svg = toSVGSVGElement(node()); 68 SVGSVGElement* svg = toSVGSVGElement(node());
69 ASSERT(svg); 69 DCHECK(svg);
70 70
71 intrinsicSizingInfo.size = 71 intrinsicSizingInfo.size =
72 FloatSize(svg->intrinsicWidth(), svg->intrinsicHeight()); 72 FloatSize(svg->intrinsicWidth(), svg->intrinsicHeight());
73 intrinsicSizingInfo.hasWidth = svg->hasIntrinsicWidth(); 73 intrinsicSizingInfo.hasWidth = svg->hasIntrinsicWidth();
74 intrinsicSizingInfo.hasHeight = svg->hasIntrinsicHeight(); 74 intrinsicSizingInfo.hasHeight = svg->hasIntrinsicHeight();
75 75
76 if (!intrinsicSizingInfo.size.isEmpty()) { 76 if (!intrinsicSizingInfo.size.isEmpty()) {
77 intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size; 77 intrinsicSizingInfo.aspectRatio = intrinsicSizingInfo.size;
78 } else { 78 } else {
79 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size(); 79 FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return LayoutUnit(m_containerSize.height()); 131 return LayoutUnit(m_containerSize.height());
132 132
133 if (isEmbeddedThroughFrameContainingSVGDocument()) 133 if (isEmbeddedThroughFrameContainingSVGDocument())
134 return containingBlock()->availableLogicalHeight( 134 return containingBlock()->availableLogicalHeight(
135 IncludeMarginBorderPadding); 135 IncludeMarginBorderPadding);
136 136
137 return LayoutReplaced::computeReplacedLogicalHeight(estimatedUsedWidth); 137 return LayoutReplaced::computeReplacedLogicalHeight(estimatedUsedWidth);
138 } 138 }
139 139
140 void LayoutSVGRoot::layout() { 140 void LayoutSVGRoot::layout() {
141 ASSERT(needsLayout()); 141 DCHECK(needsLayout());
142 LayoutAnalyzer::Scope analyzer(*this); 142 LayoutAnalyzer::Scope analyzer(*this);
143 143
144 LayoutSize oldSize = size(); 144 LayoutSize oldSize = size();
145 updateLogicalWidth(); 145 updateLogicalWidth();
146 updateLogicalHeight(); 146 updateLogicalHeight();
147 147
148 // The local-to-border-box transform is a function with the following as 148 // The local-to-border-box transform is a function with the following as
149 // input: 149 // input:
150 // 150 //
151 // * effective zoom 151 // * effective zoom
(...skipping 20 matching lines...) Expand all
172 // The scale of one or more of the SVG elements may have changed, content 172 // The scale of one or more of the SVG elements may have changed, content
173 // (the entire SVG) could have moved or new content may have been exposed, so 173 // (the entire SVG) could have moved or new content may have been exposed, so
174 // mark the entire subtree as needing paint invalidation checking. 174 // mark the entire subtree as needing paint invalidation checking.
175 if (transformChange != SVGTransformChange::None || viewportMayHaveChanged) { 175 if (transformChange != SVGTransformChange::None || viewportMayHaveChanged) {
176 setMayNeedPaintInvalidationSubtree(); 176 setMayNeedPaintInvalidationSubtree();
177 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) 177 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
178 setNeedsPaintPropertyUpdate(); 178 setNeedsPaintPropertyUpdate();
179 } 179 }
180 180
181 SVGSVGElement* svg = toSVGSVGElement(node()); 181 SVGSVGElement* svg = toSVGSVGElement(node());
182 ASSERT(svg); 182 DCHECK(svg);
183 // When hasRelativeLengths() is false, no descendants have relative lengths 183 // When hasRelativeLengths() is false, no descendants have relative lengths
184 // (hence no one is interested in viewport size changes). 184 // (hence no one is interested in viewport size changes).
185 m_isLayoutSizeChanged = viewportMayHaveChanged && svg->hasRelativeLengths(); 185 m_isLayoutSizeChanged = viewportMayHaveChanged && svg->hasRelativeLengths();
186 186
187 SVGLayoutSupport::layoutChildren( 187 SVGLayoutSupport::layoutChildren(
188 firstChild(), false, m_didScreenScaleFactorChange, m_isLayoutSizeChanged); 188 firstChild(), false, m_didScreenScaleFactorChange, m_isLayoutSizeChanged);
189 189
190 if (m_needsBoundariesOrTransformUpdate) { 190 if (m_needsBoundariesOrTransformUpdate) {
191 updateCachedBoundaries(); 191 updateCachedBoundaries();
192 m_needsBoundariesOrTransformUpdate = false; 192 m_needsBoundariesOrTransformUpdate = false;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 absolutePoint = transform.inverse().mapPoint(absolutePoint); 343 absolutePoint = transform.inverse().mapPoint(absolutePoint);
344 344
345 return closestDescendant->positionForPoint(LayoutPoint(absolutePoint)); 345 return closestDescendant->positionForPoint(LayoutPoint(absolutePoint));
346 } 346 }
347 347
348 // LayoutBox methods will expect coordinates w/o any transforms in coordinates 348 // LayoutBox methods will expect coordinates w/o any transforms in coordinates
349 // relative to our borderBox origin. This method gives us exactly that. 349 // relative to our borderBox origin. This method gives us exactly that.
350 SVGTransformChange LayoutSVGRoot::buildLocalToBorderBoxTransform() { 350 SVGTransformChange LayoutSVGRoot::buildLocalToBorderBoxTransform() {
351 SVGTransformChangeDetector changeDetector(m_localToBorderBoxTransform); 351 SVGTransformChangeDetector changeDetector(m_localToBorderBoxTransform);
352 SVGSVGElement* svg = toSVGSVGElement(node()); 352 SVGSVGElement* svg = toSVGSVGElement(node());
353 ASSERT(svg); 353 DCHECK(svg);
354 float scale = style()->effectiveZoom(); 354 float scale = style()->effectiveZoom();
355 m_localToBorderBoxTransform = svg->viewBoxToViewTransform( 355 m_localToBorderBoxTransform = svg->viewBoxToViewTransform(
356 contentWidth() / scale, contentHeight() / scale); 356 contentWidth() / scale, contentHeight() / scale);
357 357
358 FloatPoint translate = svg->currentTranslate(); 358 FloatPoint translate = svg->currentTranslate();
359 LayoutSize borderAndPadding(borderLeft() + paddingLeft(), 359 LayoutSize borderAndPadding(borderLeft() + paddingLeft(),
360 borderTop() + paddingTop()); 360 borderTop() + paddingTop());
361 AffineTransform viewToBorderBoxTransform( 361 AffineTransform viewToBorderBoxTransform(
362 scale, 0, 0, scale, borderAndPadding.width() + translate.x(), 362 scale, 0, 0, scale, borderAndPadding.width() + translate.x(),
363 borderAndPadding.height() + translate.y()); 363 borderAndPadding.height() + translate.y());
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 if (result.addNodeToListBasedTestResult(node(), locationInContainer, 484 if (result.addNodeToListBasedTestResult(node(), locationInContainer,
485 boundsRect) == StopHitTesting) 485 boundsRect) == StopHitTesting)
486 return true; 486 return true;
487 } 487 }
488 } 488 }
489 489
490 return false; 490 return false;
491 } 491 }
492 492
493 } // namespace blink 493 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698