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

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

Issue 211193002: Compute correct repaint rect for decorated RenderSVGRoots (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Only repaint the border-box when we think we have to. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/svg/custom/change-background-color-expected.html ('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) 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 11 matching lines...) Expand all
22 */ 22 */
23 23
24 #include "config.h" 24 #include "config.h"
25 25
26 #include "core/rendering/svg/RenderSVGRoot.h" 26 #include "core/rendering/svg/RenderSVGRoot.h"
27 27
28 #include "core/frame/LocalFrame.h" 28 #include "core/frame/LocalFrame.h"
29 #include "core/rendering/HitTestResult.h" 29 #include "core/rendering/HitTestResult.h"
30 #include "core/rendering/LayoutRectRecorder.h" 30 #include "core/rendering/LayoutRectRecorder.h"
31 #include "core/rendering/LayoutRepainter.h" 31 #include "core/rendering/LayoutRepainter.h"
32 #include "core/rendering/RenderLayer.h"
32 #include "core/rendering/RenderPart.h" 33 #include "core/rendering/RenderPart.h"
33 #include "core/rendering/RenderView.h" 34 #include "core/rendering/RenderView.h"
34 #include "core/rendering/svg/RenderSVGResourceContainer.h" 35 #include "core/rendering/svg/RenderSVGResourceContainer.h"
35 #include "core/rendering/svg/SVGRenderingContext.h" 36 #include "core/rendering/svg/SVGRenderingContext.h"
36 #include "core/rendering/svg/SVGResources.h" 37 #include "core/rendering/svg/SVGResources.h"
37 #include "core/rendering/svg/SVGResourcesCache.h" 38 #include "core/rendering/svg/SVGResourcesCache.h"
38 #include "core/svg/SVGElement.h" 39 #include "core/svg/SVGElement.h"
39 #include "core/svg/SVGSVGElement.h" 40 #include "core/svg/SVGSVGElement.h"
40 #include "core/svg/graphics/SVGImage.h" 41 #include "core/svg/graphics/SVGImage.h"
41 #include "platform/LengthFunctions.h" 42 #include "platform/LengthFunctions.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 { 347 {
347 // Slightly optimized version of m_localToParentTransform = AffineTransform: :translation(x(), y()) * m_localToBorderBoxTransform; 348 // Slightly optimized version of m_localToParentTransform = AffineTransform: :translation(x(), y()) * m_localToBorderBoxTransform;
348 m_localToParentTransform = m_localToBorderBoxTransform; 349 m_localToParentTransform = m_localToBorderBoxTransform;
349 if (x()) 350 if (x())
350 m_localToParentTransform.setE(m_localToParentTransform.e() + roundToInt( x())); 351 m_localToParentTransform.setE(m_localToParentTransform.e() + roundToInt( x()));
351 if (y()) 352 if (y())
352 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt( y())); 353 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt( y()));
353 return m_localToParentTransform; 354 return m_localToParentTransform;
354 } 355 }
355 356
357 static bool shouldRepaintBorderBox(const RenderObject& object)
358 {
359 // If it's the document root, then include the border-box in the repaint
360 // rect if it's got a background or a border specified. This is a reduced
361 // version of the predicate found in RenderBoxModelObject::updateFromStyle,
362 // that is used to set the hasBoxDecorations flag. The reason it's used at
363 // all is because said flag is unconditionally set to 'true' for the
364 // document root.
365 if (object.isRoot())
pdr. 2014/04/01 18:55:48 Should this be an assert instead of a conditional?
fs 2014/04/02 08:01:54 You mean: ASSERT(object.isRoot()); (or the negat
366 return object.hasBackground() || object.style()->hasBorder();
pdr. 2014/04/01 18:55:48 I suspect there are additional accoutrements we're
fs 2014/04/02 08:01:54 The "original" check/predicate (from RenderBoxMode
367 // Otherwise, consider all box decorations.
368 return object.hasBoxDecorations();
369 }
370
356 LayoutRect RenderSVGRoot::clippedOverflowRectForRepaint(const RenderLayerModelOb ject* repaintContainer) const 371 LayoutRect RenderSVGRoot::clippedOverflowRectForRepaint(const RenderLayerModelOb ject* repaintContainer) const
357 { 372 {
358 return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContaine r); 373 // This is an open-coded aggregate of SVGRenderSupport::clippedOverflowRectF orRepaint,
pdr. 2014/04/01 18:55:48 This is a lot of code but it's sort of expected fo
pdr. 2014/04/02 06:15:31 Looking at this again, I see falling back to regul
fs 2014/04/02 08:01:54 I look into 'outline', and the mentioned transitio
374 // RenderSVGRoot::computeFloatRectForRepaint and RenderReplaced::clippedOver flowRectForRepaint.
375 // The reason for this is to optimize/minimize the repaint rect when the box is not "decorated"
376 // (does not have background/border/etc.)
377
378 // Return early for any cases where we don't actually paint.
379 if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent ())
380 return LayoutRect();
381
382 // Compute the repaint rect of the content of the SVG in the border-box coor dinate space.
383 FloatRect contentRepaintRect = repaintRectInLocalCoordinates();
384 contentRepaintRect = m_localToBorderBoxTransform.mapRect(contentRepaintRect) ;
385
386 // Apply initial viewport clip - not affected by overflow settings
387 contentRepaintRect.intersect(pixelSnappedBorderBoxRect());
388
389 LayoutRect repaintRect = enclosingLayoutRect(contentRepaintRect);
390 // If the box is decorated, extend it to include the border-box.
391 if (shouldRepaintBorderBox(*this)) {
pdr. 2014/04/01 18:55:48 I see how this can work when changing or gaining a
392 // The selectionRect can project outside of the overflowRect, so take th eir union
393 // for repainting to avoid selection painting glitches.
394 LayoutRect decoratedRepaintRect = unionRect(localSelectionRect(false), v isualOverflowRect());
395 repaintRect.unite(decoratedRepaintRect);
396 }
397
398 // Compute the repaint rect in the parent coordinate space.
399 LayoutRect rect = enclosingIntRect(repaintRect);
400 RenderReplaced::computeRectForRepaint(repaintContainer, rect);
401 return rect;
359 } 402 }
360 403
361 void RenderSVGRoot::computeFloatRectForRepaint(const RenderLayerModelObject* rep aintContainer, FloatRect& repaintRect, bool fixed) const 404 void RenderSVGRoot::computeFloatRectForRepaint(const RenderLayerModelObject* rep aintContainer, FloatRect& repaintRect, bool fixed) const
362 { 405 {
363 // Apply our local transforms (except for x/y translation), then our shadow, 406 // Apply our local transforms (except for x/y translation), then our shadow,
364 // and then call RenderBox's method to handle all the normal CSS Box model b its 407 // and then call RenderBox's method to handle all the normal CSS Box model b its
365 repaintRect = m_localToBorderBoxTransform.mapRect(repaintRect); 408 repaintRect = m_localToBorderBoxTransform.mapRect(repaintRect);
366 409
367 // Apply initial viewport clip - not affected by overflow settings 410 // Apply initial viewport clip - not affected by overflow settings
368 repaintRect.intersect(pixelSnappedBorderBoxRect()); 411 repaintRect.intersect(pixelSnappedBorderBoxRect());
(...skipping 16 matching lines...) Expand all
385 428
386 const RenderObject* RenderSVGRoot::pushMappingToContainer(const RenderLayerModel Object* ancestorToStopAt, RenderGeometryMap& geometryMap) const 429 const RenderObject* RenderSVGRoot::pushMappingToContainer(const RenderLayerModel Object* ancestorToStopAt, RenderGeometryMap& geometryMap) const
387 { 430 {
388 return RenderReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap) ; 431 return RenderReplaced::pushMappingToContainer(ancestorToStopAt, geometryMap) ;
389 } 432 }
390 433
391 void RenderSVGRoot::updateCachedBoundaries() 434 void RenderSVGRoot::updateCachedBoundaries()
392 { 435 {
393 SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m _objectBoundingBoxValid, m_strokeBoundingBox, m_repaintBoundingBox); 436 SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m _objectBoundingBoxValid, m_strokeBoundingBox, m_repaintBoundingBox);
394 SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingB ox); 437 SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingB ox);
395 m_repaintBoundingBox.inflate(borderAndPaddingWidth().toFloat());
396 } 438 }
397 439
398 bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction) 440 bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated Offset, HitTestAction hitTestAction)
399 { 441 {
400 LayoutPoint pointInParent = locationInContainer.point() - toLayoutSize(accum ulatedOffset); 442 LayoutPoint pointInParent = locationInContainer.point() - toLayoutSize(accum ulatedOffset);
401 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location()); 443 LayoutPoint pointInBorderBox = pointInParent - toLayoutSize(location());
402 444
403 // Only test SVG content if the point is in our content box. 445 // Only test SVG content if the point is in our content box.
404 // FIXME: This should be an intersection when rect-based hit tests are suppo rted by nodeAtFloatPoint. 446 // FIXME: This should be an intersection when rect-based hit tests are suppo rted by nodeAtFloatPoint.
405 if (contentBoxRect().contains(pointInBorderBox)) { 447 if (contentBoxRect().contains(pointInBorderBox)) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 483
442 bool RenderSVGRoot::hasRelativeLogicalHeight() const 484 bool RenderSVGRoot::hasRelativeLogicalHeight() const
443 { 485 {
444 SVGSVGElement* svg = toSVGSVGElement(node()); 486 SVGSVGElement* svg = toSVGSVGElement(node());
445 ASSERT(svg); 487 ASSERT(svg);
446 488
447 return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent(); 489 return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent();
448 } 490 }
449 491
450 } 492 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/custom/change-background-color-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698