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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.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) 2007, 2008 Rob Buis <buis@kde.org> 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org>
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@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. All rights reserved. 5 * Copyright (C) 2009 Google, Inc. All rights reserved.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 void SVGLayoutSupport::mapAncestorToLocal(const LayoutObject& object, 157 void SVGLayoutSupport::mapAncestorToLocal(const LayoutObject& object,
158 const LayoutBoxModelObject* ancestor, 158 const LayoutBoxModelObject* ancestor,
159 TransformState& transformState, 159 TransformState& transformState,
160 MapCoordinatesFlags flags) { 160 MapCoordinatesFlags flags) {
161 // |object| is either a LayoutSVGModelObject or a LayoutSVGBlock here. In 161 // |object| is either a LayoutSVGModelObject or a LayoutSVGBlock here. In
162 // the former case, |object| can never be an ancestor while in the latter 162 // the former case, |object| can never be an ancestor while in the latter
163 // the caller is responsible for doing the ancestor check. Because of this, 163 // the caller is responsible for doing the ancestor check. Because of this,
164 // computing the transform to the SVG root is always what we want to do here. 164 // computing the transform to the SVG root is always what we want to do here.
165 ASSERT(ancestor != &object); 165 DCHECK_NE(ancestor, &object);
166 ASSERT(object.isSVGContainer() || object.isSVGShape() || 166 DCHECK(object.isSVGContainer() || object.isSVGShape() ||
167 object.isSVGImage() || object.isSVGText() || 167 object.isSVGImage() || object.isSVGText() ||
168 object.isSVGForeignObject()); 168 object.isSVGForeignObject());
169 AffineTransform localToSVGRoot; 169 AffineTransform localToSVGRoot;
170 const LayoutSVGRoot& svgRoot = 170 const LayoutSVGRoot& svgRoot =
171 computeTransformToSVGRoot(object, localToSVGRoot); 171 computeTransformToSVGRoot(object, localToSVGRoot);
172 172
173 MapCoordinatesFlags mode = flags | UseTransforms | ApplyContainerFlip; 173 MapCoordinatesFlags mode = flags | UseTransforms | ApplyContainerFlip;
174 svgRoot.mapAncestorToLocal(ancestor, transformState, mode); 174 svgRoot.mapAncestorToLocal(ancestor, transformState, mode);
175 175
176 transformState.applyTransform(localToSVGRoot); 176 transformState.applyTransform(localToSVGRoot);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 localVisualRect = strokeBoundingBox; 261 localVisualRect = strokeBoundingBox;
262 adjustVisualRectWithResources(container, localVisualRect); 262 adjustVisualRectWithResources(container, localVisualRect);
263 } 263 }
264 264
265 const LayoutSVGRoot* SVGLayoutSupport::findTreeRootObject( 265 const LayoutSVGRoot* SVGLayoutSupport::findTreeRootObject(
266 const LayoutObject* start) { 266 const LayoutObject* start) {
267 while (start && !start->isSVGRoot()) 267 while (start && !start->isSVGRoot())
268 start = start->parent(); 268 start = start->parent();
269 269
270 ASSERT(start); 270 DCHECK(start);
271 ASSERT(start->isSVGRoot()); 271 DCHECK(start->isSVGRoot());
272 return toLayoutSVGRoot(start); 272 return toLayoutSVGRoot(start);
273 } 273 }
274 274
275 bool SVGLayoutSupport::layoutSizeOfNearestViewportChanged( 275 bool SVGLayoutSupport::layoutSizeOfNearestViewportChanged(
276 const LayoutObject* start) { 276 const LayoutObject* start) {
277 for (; start; start = start->parent()) { 277 for (; start; start = start->parent()) {
278 if (start->isSVGRoot()) 278 if (start->isSVGRoot())
279 return toLayoutSVGRoot(start)->isLayoutSizeChanged(); 279 return toLayoutSVGRoot(start)->isLayoutSizeChanged();
280 if (start->isSVGViewportContainer()) 280 if (start->isSVGViewportContainer())
281 return toLayoutSVGViewportContainer(start)->isLayoutSizeChanged(); 281 return toLayoutSVGViewportContainer(start)->isLayoutSizeChanged();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::SvgChanged); 354 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::SvgChanged);
355 355
356 // Lay out any referenced resources before the child. 356 // Lay out any referenced resources before the child.
357 layoutResourcesIfNeeded(child); 357 layoutResourcesIfNeeded(child);
358 child->layoutIfNeeded(); 358 child->layoutIfNeeded();
359 } 359 }
360 } 360 }
361 } 361 }
362 362
363 void SVGLayoutSupport::layoutResourcesIfNeeded(const LayoutObject* object) { 363 void SVGLayoutSupport::layoutResourcesIfNeeded(const LayoutObject* object) {
364 ASSERT(object); 364 DCHECK(object);
365 365
366 SVGResources* resources = 366 SVGResources* resources =
367 SVGResourcesCache::cachedResourcesForLayoutObject(object); 367 SVGResourcesCache::cachedResourcesForLayoutObject(object);
368 if (resources) 368 if (resources)
369 resources->layoutIfNeeded(); 369 resources->layoutIfNeeded();
370 } 370 }
371 371
372 bool SVGLayoutSupport::isOverflowHidden(const LayoutObject* object) { 372 bool SVGLayoutSupport::isOverflowHidden(const LayoutObject* object) {
373 // LayoutSVGRoot should never query for overflow state - it should always clip 373 // LayoutSVGRoot should never query for overflow state - it should always clip
374 // itself to the initial viewport size. 374 // itself to the initial viewport size.
375 ASSERT(!object->isDocumentElement()); 375 DCHECK(!object->isDocumentElement());
376 376
377 return object->style()->overflowX() == EOverflow::kHidden || 377 return object->style()->overflowX() == EOverflow::kHidden ||
378 object->style()->overflowX() == EOverflow::kScroll; 378 object->style()->overflowX() == EOverflow::kScroll;
379 } 379 }
380 380
381 void SVGLayoutSupport::adjustVisualRectWithResources( 381 void SVGLayoutSupport::adjustVisualRectWithResources(
382 const LayoutObject* layoutObject, 382 const LayoutObject* layoutObject,
383 FloatRect& visualRect) { 383 FloatRect& visualRect) {
384 ASSERT(layoutObject); 384 DCHECK(layoutObject);
385 385
386 SVGResources* resources = 386 SVGResources* resources =
387 SVGResourcesCache::cachedResourcesForLayoutObject(layoutObject); 387 SVGResourcesCache::cachedResourcesForLayoutObject(layoutObject);
388 if (!resources) 388 if (!resources)
389 return; 389 return;
390 390
391 if (LayoutSVGResourceFilter* filter = resources->filter()) 391 if (LayoutSVGResourceFilter* filter = resources->filter())
392 visualRect = filter->resourceBoundingBox(layoutObject); 392 visualRect = filter->resourceBoundingBox(layoutObject);
393 393
394 if (LayoutSVGResourceClipper* clipper = resources->clipper()) 394 if (LayoutSVGResourceClipper* clipper = resources->clipper())
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 DashArray dashArray; 442 DashArray dashArray;
443 for (const Length& dashLength : svgDashArray.vector()) 443 for (const Length& dashLength : svgDashArray.vector())
444 dashArray.push_back(lengthContext.valueForLength(dashLength, style)); 444 dashArray.push_back(lengthContext.valueForLength(dashLength, style));
445 return dashArray; 445 return dashArray;
446 } 446 }
447 447
448 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData, 448 void SVGLayoutSupport::applyStrokeStyleToStrokeData(StrokeData& strokeData,
449 const ComputedStyle& style, 449 const ComputedStyle& style,
450 const LayoutObject& object, 450 const LayoutObject& object,
451 float dashScaleFactor) { 451 float dashScaleFactor) {
452 ASSERT(object.node()); 452 DCHECK(object.node());
453 ASSERT(object.node()->isSVGElement()); 453 DCHECK(object.node()->isSVGElement());
454 454
455 const SVGComputedStyle& svgStyle = style.svgStyle(); 455 const SVGComputedStyle& svgStyle = style.svgStyle();
456 456
457 SVGLengthContext lengthContext(toSVGElement(object.node())); 457 SVGLengthContext lengthContext(toSVGElement(object.node()));
458 strokeData.setThickness(lengthContext.valueForLength(svgStyle.strokeWidth())); 458 strokeData.setThickness(lengthContext.valueForLength(svgStyle.strokeWidth()));
459 strokeData.setLineCap(svgStyle.capStyle()); 459 strokeData.setLineCap(svgStyle.capStyle());
460 strokeData.setLineJoin(svgStyle.joinStyle()); 460 strokeData.setLineJoin(svgStyle.joinStyle());
461 strokeData.setMiterLimit(svgStyle.strokeMiterLimit()); 461 strokeData.setMiterLimit(svgStyle.strokeMiterLimit());
462 462
463 DashArray dashArray = 463 DashArray dashArray =
464 resolveSVGDashArray(*svgStyle.strokeDashArray(), style, lengthContext); 464 resolveSVGDashArray(*svgStyle.strokeDashArray(), style, lengthContext);
465 float dashOffset = 465 float dashOffset =
466 lengthContext.valueForLength(svgStyle.strokeDashOffset(), style); 466 lengthContext.valueForLength(svgStyle.strokeDashOffset(), style);
467 // Apply scaling from 'pathLength'. 467 // Apply scaling from 'pathLength'.
468 if (dashScaleFactor != 1) { 468 if (dashScaleFactor != 1) {
469 ASSERT(dashScaleFactor >= 0); 469 DCHECK_GE(dashScaleFactor, 0);
470 dashOffset *= dashScaleFactor; 470 dashOffset *= dashScaleFactor;
471 for (auto& dashItem : dashArray) 471 for (auto& dashItem : dashArray)
472 dashItem *= dashScaleFactor; 472 dashItem *= dashScaleFactor;
473 } 473 }
474 strokeData.setLineDash(dashArray, dashOffset); 474 strokeData.setLineDash(dashArray, dashOffset);
475 } 475 }
476 476
477 bool SVGLayoutSupport::isLayoutableTextNode(const LayoutObject* object) { 477 bool SVGLayoutSupport::isLayoutableTextNode(const LayoutObject* object) {
478 ASSERT(object->isText()); 478 DCHECK(object->isText());
479 // <br> is marked as text, but is not handled by the SVG layout code-path. 479 // <br> is marked as text, but is not handled by the SVG layout code-path.
480 return object->isSVGInlineText() && 480 return object->isSVGInlineText() &&
481 !toLayoutSVGInlineText(object)->hasEmptyText(); 481 !toLayoutSVGInlineText(object)->hasEmptyText();
482 } 482 }
483 483
484 bool SVGLayoutSupport::willIsolateBlendingDescendantsForStyle( 484 bool SVGLayoutSupport::willIsolateBlendingDescendantsForStyle(
485 const ComputedStyle& style) { 485 const ComputedStyle& style) {
486 const SVGComputedStyle& svgStyle = style.svgStyle(); 486 const SVGComputedStyle& svgStyle = style.svgStyle();
487 487
488 return style.hasIsolation() || style.opacity() < 1 || style.hasBlendMode() || 488 return style.hasIsolation() || style.opacity() < 1 || style.hasBlendMode() ||
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 } 609 }
610 610
611 LayoutObject* SVGLayoutSupport::findClosestLayoutSVGText( 611 LayoutObject* SVGLayoutSupport::findClosestLayoutSVGText(
612 LayoutObject* layoutObject, 612 LayoutObject* layoutObject,
613 const FloatPoint& point) { 613 const FloatPoint& point) {
614 return searchTreeForFindClosestLayoutSVGText(layoutObject, point) 614 return searchTreeForFindClosestLayoutSVGText(layoutObject, point)
615 .candidateLayoutObject; 615 .candidateLayoutObject;
616 } 616 }
617 617
618 } // namespace blink 618 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698