Changeset 112091 in webkit
- Timestamp:
- Mar 26, 2012 7:36:59 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r112086 r112091 1 2012-03-26 Philip Rogers <pdr@google.com> 2 3 Add invalid bounding box concept to SVG containers 4 https://bugs.webkit.org/show_bug.cgi?id=81104 5 6 Reviewed by Nikolas Zimmermann. 7 8 * svg/custom/getBBox-empty-container-expected.txt: Added. 9 * svg/custom/getBBox-empty-container.html: Added. 10 1 11 2012-03-26 Pavel Feldman <pfeldman@chromium.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r112090 r112091 1 2012-03-26 Philip Rogers <pdr@google.com> 2 3 Add invalid bounding box concept to SVG containers 4 https://bugs.webkit.org/show_bug.cgi?id=81104 5 6 Reviewed by Nikolas Zimmermann. 7 8 An empty <g> element needs to use an invalid bounding box because 9 an empty bounding box isn't the default state. This change 10 introduces the concept of an invalid object bounding box for 11 both RenderSVGContainer and RenderSVGRoot. Code that 12 does not explicitly check that the bounding box is valid 13 should be unaffected by this change. We use this new invalid 14 flag in computeContainerBoundingBoxes so that we do not 15 include invalid bounding boxes. 16 17 This change also contains a small fix in 18 RenderSVGContainer::toRenderSVGContainer which depended on 19 RenderSVGViewportContainer not inheriting from RenderSVGContainer, 20 which it now does. 21 22 Test: svg/custom/getBBox-empty-container.html 23 24 * rendering/svg/RenderSVGContainer.cpp: 25 (WebCore::RenderSVGContainer::RenderSVGContainer): 26 (WebCore::RenderSVGContainer::updateCachedBoundaries): 27 * rendering/svg/RenderSVGContainer.h: 28 (WebCore::RenderSVGContainer::isObjectBoundingBoxValid): 29 (RenderSVGContainer): 30 (WebCore::toRenderSVGContainer): 31 * rendering/svg/RenderSVGRoot.cpp: 32 (WebCore::RenderSVGRoot::RenderSVGRoot): 33 (WebCore::RenderSVGRoot::updateCachedBoundaries): 34 * rendering/svg/RenderSVGRoot.h: 35 (RenderSVGRoot): 36 * rendering/svg/SVGRenderSupport.cpp: 37 (WebCore): 38 (WebCore::updateObjectBoundingBox): 39 (WebCore::SVGRenderSupport::computeContainerBoundingBoxes): 40 * rendering/svg/SVGRenderSupport.h: 41 (SVGRenderSupport): 42 1 43 2012-03-26 Alexei Filippov <alexeif@chromium.org> 2 44 -
trunk/Source/WebCore/rendering/svg/RenderSVGContainer.cpp
r110285 r112091 41 41 RenderSVGContainer::RenderSVGContainer(SVGStyledElement* node) 42 42 : RenderSVGModelObject(node) 43 , m_objectBoundingBoxValid(false) 43 44 , m_needsBoundariesUpdate(true) 44 45 { … … 151 152 { 152 153 m_objectBoundingBox = FloatRect(); 154 m_objectBoundingBoxValid = false; 153 155 m_strokeBoundingBox = FloatRect(); 154 156 m_repaintBoundingBox = FloatRect(); 155 157 156 SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m_ strokeBoundingBox, m_repaintBoundingBox);158 SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m_objectBoundingBoxValid, m_strokeBoundingBox, m_repaintBoundingBox); 157 159 SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingBox); 158 160 } -
trunk/Source/WebCore/rendering/svg/RenderSVGContainer.h
r110224 r112091 43 43 virtual void setNeedsBoundariesUpdate() { m_needsBoundariesUpdate = true; } 44 44 virtual bool didTransformToRootUpdate() { return false; } 45 bool isObjectBoundingBoxValid() const { return m_objectBoundingBoxValid; } 45 46 46 47 protected: … … 77 78 RenderObjectChildList m_children; 78 79 FloatRect m_objectBoundingBox; 80 bool m_objectBoundingBoxValid; 79 81 FloatRect m_strokeBoundingBox; 80 82 FloatRect m_repaintBoundingBox; … … 84 86 inline RenderSVGContainer* toRenderSVGContainer(RenderObject* object) 85 87 { 86 // Note: isSVGContainer is also true for RenderSVGViewportContainer, which is not derived from this. 87 ASSERT(!object || (object->isSVGContainer() && strcmp(object->renderName(), "RenderSVGViewportContainer"))); 88 ASSERT(!object || object->isSVGContainer()); 88 89 return static_cast<RenderSVGContainer*>(object); 89 90 } … … 91 92 inline const RenderSVGContainer* toRenderSVGContainer(const RenderObject* object) 92 93 { 93 // Note: isSVGContainer is also true for RenderSVGViewportContainer, which is not derived from this. 94 ASSERT(!object || (object->isSVGContainer() && strcmp(object->renderName(), "RenderSVGViewportContainer"))); 94 ASSERT(!object || object->isSVGContainer()); 95 95 return static_cast<const RenderSVGContainer*>(object); 96 96 } -
trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp
r111626 r112091 58 58 RenderSVGRoot::RenderSVGRoot(SVGStyledElement* node) 59 59 : RenderReplaced(node) 60 , m_objectBoundingBoxValid(false) 60 61 , m_isLayoutSizeChanged(false) 61 62 , m_needsBoundariesOrTransformUpdate(true) … … 393 394 { 394 395 m_objectBoundingBox = FloatRect(); 396 m_objectBoundingBoxValid = false; 395 397 m_strokeBoundingBox = FloatRect(); 396 398 m_repaintBoundingBox = FloatRect(); 397 399 398 SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m_ strokeBoundingBox, m_repaintBoundingBox);400 SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m_objectBoundingBoxValid, m_strokeBoundingBox, m_repaintBoundingBox); 399 401 SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingBox); 400 402 m_repaintBoundingBox.inflate(borderAndPaddingWidth()); -
trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h
r111601 r112091 105 105 IntSize m_containerSize; 106 106 FloatRect m_objectBoundingBox; 107 bool m_objectBoundingBoxValid; 107 108 FloatRect m_strokeBoundingBox; 108 109 FloatRect m_repaintBoundingBox; -
trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp
r111176 r112091 86 86 } 87 87 88 void SVGRenderSupport::computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox) 89 { 90 bool isFirstChild = true; 91 88 // Update a bounding box taking into account the validity of the other bounding box. 89 static inline void updateObjectBoundingBox(FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, RenderObject* other, FloatRect otherBoundingBox) 90 { 91 bool otherValid = other->isSVGContainer() ? toRenderSVGContainer(other)->isObjectBoundingBoxValid() : true; 92 if (!otherValid) 93 return; 94 95 if (!objectBoundingBoxValid) { 96 objectBoundingBox = otherBoundingBox; 97 objectBoundingBoxValid = true; 98 return; 99 } 100 101 objectBoundingBox.uniteEvenIfEmpty(otherBoundingBox); 102 } 103 104 void SVGRenderSupport::computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox) 105 { 92 106 for (RenderObject* current = container->firstChild(); current; current = current->nextSibling()) { 93 107 if (current->isSVGHiddenContainer()) … … 96 110 const AffineTransform& transform = current->localToParentTransform(); 97 111 if (transform.isIdentity()) { 98 if (isFirstChild) 99 objectBoundingBox = current->objectBoundingBox(); 100 else 101 objectBoundingBox.uniteEvenIfEmpty(current->objectBoundingBox()); 112 updateObjectBoundingBox(objectBoundingBox, objectBoundingBoxValid, current, current->objectBoundingBox()); 102 113 strokeBoundingBox.unite(current->strokeBoundingBox()); 103 114 repaintBoundingBox.unite(current->repaintRectInLocalCoordinates()); 104 115 } else { 105 if (isFirstChild) 106 objectBoundingBox = transform.mapRect(current->objectBoundingBox()); 107 else 108 objectBoundingBox.uniteEvenIfEmpty(transform.mapRect(current->objectBoundingBox())); 116 updateObjectBoundingBox(objectBoundingBox, objectBoundingBoxValid, current, transform.mapRect(current->objectBoundingBox())); 109 117 strokeBoundingBox.unite(transform.mapRect(current->strokeBoundingBox())); 110 118 repaintBoundingBox.unite(transform.mapRect(current->repaintRectInLocalCoordinates())); 111 119 } 112 113 isFirstChild = false;114 120 } 115 121 } -
trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h
r110285 r112091 58 58 static bool pointInClippingArea(RenderObject*, const FloatPoint&); 59 59 60 static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox);60 static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, bool& objectBoundingBoxValid, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox); 61 61 static bool paintInfoIntersectsRepaintRect(const FloatRect& localRepaintRect, const AffineTransform& localTransform, const PaintInfo&); 62 62
Note: See TracChangeset
for help on using the changeset viewer.