Reviewed by Dirk Schulze.
Add culling to RenderSVGContainer
https://bugs.webkit.org/show_bug.cgi?id=44896
Cache object/strokeBoundingBox and repaintRectInLocalCoordinates() in RenderSVGContainer & RenderSVGRoot, just like it's done in RenderPath.
Propagate boundary changes up the render tree, in layout phase, in order to notify parents that they should update their cached boundaries.
This is a huge speed benefit when interacting with an already layouted document, as there's no need anymore to traverse all children
of any container or <svg> element, just to retrieve the repaint rect.
* rendering/RenderForeignObject.cpp:
(WebCore::RenderForeignObject::layout):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::setNeedsBoundariesUpdate):
* rendering/RenderObject.h:
* rendering/RenderObjectChildList.cpp:
(WebCore::RenderObjectChildList::removeChildNode):
* rendering/RenderPath.cpp:
(WebCore::RenderPath::layout):
(WebCore::RenderPath::paint):
* rendering/RenderPath.h:
(WebCore::RenderPath::path):
(WebCore::RenderPath::setNeedsBoundariesUpdate):
* rendering/RenderSVGBlock.cpp:
(WebCore::RenderSVGBlock::styleWillChange):
* rendering/RenderSVGBlock.h:
* rendering/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::RenderSVGContainer):
(WebCore::RenderSVGContainer::layout):
(WebCore::RenderSVGContainer::paint):
(WebCore::RenderSVGContainer::updateCachedBoundaries):
* rendering/RenderSVGContainer.h:
(WebCore::RenderSVGContainer::setNeedsBoundariesUpdate):
(WebCore::RenderSVGContainer::objectBoundingBox):
(WebCore::RenderSVGContainer::strokeBoundingBox):
(WebCore::RenderSVGContainer::repaintRectInLocalCoordinates):
(WebCore::RenderSVGContainer::calculateLocalTransform):
* rendering/RenderSVGGradientStop.h:
(WebCore::RenderSVGGradientStop::strokeBoundingBox):
* rendering/RenderSVGHiddenContainer.cpp:
* rendering/RenderSVGHiddenContainer.h:
(WebCore::RenderSVGHiddenContainer::clippedOverflowRectForRepaint):
* rendering/RenderSVGImage.cpp:
(WebCore::RenderSVGImage::layout):
(WebCore::RenderSVGImage::styleWillChange):
* rendering/RenderSVGImage.h:
* rendering/RenderSVGInline.cpp:
(WebCore::RenderSVGInline::styleWillChange):
* rendering/RenderSVGInline.h:
* rendering/RenderSVGModelObject.cpp:
(WebCore::RenderSVGModelObject::styleWillChange):
* rendering/RenderSVGModelObject.h:
* rendering/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::RenderSVGRoot):
(WebCore::RenderSVGRoot::layout):
(WebCore::RenderSVGRoot::styleWillChange):
(WebCore::RenderSVGRoot::updateCachedBoundaries):
* rendering/RenderSVGRoot.h:
(WebCore::RenderSVGRoot::setNeedsBoundariesUpdate):
(WebCore::RenderSVGRoot::setNeedsTransformUpdate):
(WebCore::RenderSVGRoot::objectBoundingBox):
(WebCore::RenderSVGRoot::strokeBoundingBox):
(WebCore::RenderSVGRoot::repaintRectInLocalCoordinates):
* rendering/RenderSVGText.cpp:
(WebCore::RenderSVGText::layout):
* rendering/RenderSVGTransformableContainer.cpp:
(WebCore::RenderSVGTransformableContainer::calculateLocalTransform):
* rendering/RenderSVGTransformableContainer.h:
* rendering/RenderSVGViewportContainer.cpp:
(WebCore::RenderSVGViewportContainer::calcViewport):
* rendering/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::computeContainerBoundingBoxes):
(WebCore::SVGRenderSupport::paintInfoIntersectsRepaintRect):
* rendering/SVGRenderSupport.h:
* rendering/style/SVGRenderStyle.cpp:
(WebCore::SVGRenderStyle::diff):
2010-08-30 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Dirk Schulze.
Add culling to RenderSVGContainer
https://bugs.webkit.org/show_bug.cgi?id=44896
Update some pixel test results, that show marginal changes.
* platform/mac-leopard/svg/css/composite-shadow-example-expected.checksum:
* platform/mac-leopard/svg/css/composite-shadow-example-expected.png:
* platform/mac-leopard/svg/css/composite-shadow-with-opacity-expected.checksum:
* platform/mac-leopard/svg/css/composite-shadow-with-opacity-expected.png:
* platform/mac/svg/css/composite-shadow-example-expected.txt:
* platform/mac/svg/css/composite-shadow-with-opacity-expected.txt:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@66418
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2010-08-30 Nikolas Zimmermann <nzimmermann@rim.com>
+
+ Reviewed by Dirk Schulze.
+
+ Add culling to RenderSVGContainer
+ https://bugs.webkit.org/show_bug.cgi?id=44896
+
+ Update some pixel test results, that show marginal changes.
+
+ * platform/mac-leopard/svg/css/composite-shadow-example-expected.checksum:
+ * platform/mac-leopard/svg/css/composite-shadow-example-expected.png:
+ * platform/mac-leopard/svg/css/composite-shadow-with-opacity-expected.checksum:
+ * platform/mac-leopard/svg/css/composite-shadow-with-opacity-expected.png:
+ * platform/mac/svg/css/composite-shadow-example-expected.txt:
+ * platform/mac/svg/css/composite-shadow-with-opacity-expected.txt:
+
2010-08-27 Jer Noble <jer.noble@apple.com>
Reviewed by Eric Carlson.
-85e4e03902685db9779422cee76a38b7
\ No newline at end of file
+8161131336b1925ffe396e63db173b6b
\ No newline at end of file
-37ce6f48a37bde5464635bcc0926a03a
\ No newline at end of file
+87c3a71c83dd3602d760dc1558148679
\ No newline at end of file
layer at (0,0) size 785x616
RenderBlock {HTML} at (0,0) size 785x616
RenderBody {BODY} at (8,8) size 769x600
- RenderSVGRoot {svg} at (40,36) size 436x150
+ RenderSVGRoot {svg} at (40,36) size 446x160
RenderSVGContainer {g} at (40,36) size 146x140
RenderPath {path} at (40,36) size 146x140 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,100.00)}] [stroke={[type=SOLID] [color=#000000] [stroke width=10.00]}] [fill={[type=SOLID] [color=#999999]}] [data="M0.00,30.00 L-35.27,48.54 L-28.53,9.27 L-57.06,-18.54 L-17.63,-24.27 L-0.00,-60.00 L17.63,-24.27 L57.06,-18.54 L28.53,9.27 L35.27,48.54 Z"]
RenderSVGContainer {g} at (200,46) size 128x125
RenderBlock {HTML} at (0,0) size 785x616
RenderBody {BODY} at (8,8) size 769x600
layer at (8,8) size 769x600
- RenderSVGRoot {svg} at (40,36) size 436x150 [opacity=0.50]
+ RenderSVGRoot {svg} at (40,36) size 446x160 [opacity=0.50]
RenderSVGContainer {g} at (40,36) size 146x140
RenderPath {path} at (40,36) size 146x140 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,100.00)}] [stroke={[type=SOLID] [color=#000000] [stroke width=10.00]}] [fill={[type=SOLID] [color=#999999]}] [data="M0.00,30.00 L-35.27,48.54 L-28.53,9.27 L-57.06,-18.54 L-17.63,-24.27 L-0.00,-60.00 L17.63,-24.27 L57.06,-18.54 L28.53,9.27 L35.27,48.54 Z"]
RenderSVGContainer {g} at (200,46) size 128x125
+2010-08-30 Nikolas Zimmermann <nzimmermann@rim.com>
+
+ Reviewed by Dirk Schulze.
+
+ Add culling to RenderSVGContainer
+ https://bugs.webkit.org/show_bug.cgi?id=44896
+
+ Cache object/strokeBoundingBox and repaintRectInLocalCoordinates() in RenderSVGContainer & RenderSVGRoot, just like it's done in RenderPath.
+ Propagate boundary changes up the render tree, in layout phase, in order to notify parents that they should update their cached boundaries.
+
+ This is a huge speed benefit when interacting with an already layouted document, as there's no need anymore to traverse all children
+ of any container or <svg> element, just to retrieve the repaint rect.
+
+ * rendering/RenderForeignObject.cpp:
+ (WebCore::RenderForeignObject::layout):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::setNeedsBoundariesUpdate):
+ * rendering/RenderObject.h:
+ * rendering/RenderObjectChildList.cpp:
+ (WebCore::RenderObjectChildList::removeChildNode):
+ * rendering/RenderPath.cpp:
+ (WebCore::RenderPath::layout):
+ (WebCore::RenderPath::paint):
+ * rendering/RenderPath.h:
+ (WebCore::RenderPath::path):
+ (WebCore::RenderPath::setNeedsBoundariesUpdate):
+ * rendering/RenderSVGBlock.cpp:
+ (WebCore::RenderSVGBlock::styleWillChange):
+ * rendering/RenderSVGBlock.h:
+ * rendering/RenderSVGContainer.cpp:
+ (WebCore::RenderSVGContainer::RenderSVGContainer):
+ (WebCore::RenderSVGContainer::layout):
+ (WebCore::RenderSVGContainer::paint):
+ (WebCore::RenderSVGContainer::updateCachedBoundaries):
+ * rendering/RenderSVGContainer.h:
+ (WebCore::RenderSVGContainer::setNeedsBoundariesUpdate):
+ (WebCore::RenderSVGContainer::objectBoundingBox):
+ (WebCore::RenderSVGContainer::strokeBoundingBox):
+ (WebCore::RenderSVGContainer::repaintRectInLocalCoordinates):
+ (WebCore::RenderSVGContainer::calculateLocalTransform):
+ * rendering/RenderSVGGradientStop.h:
+ (WebCore::RenderSVGGradientStop::strokeBoundingBox):
+ * rendering/RenderSVGHiddenContainer.cpp:
+ * rendering/RenderSVGHiddenContainer.h:
+ (WebCore::RenderSVGHiddenContainer::clippedOverflowRectForRepaint):
+ * rendering/RenderSVGImage.cpp:
+ (WebCore::RenderSVGImage::layout):
+ (WebCore::RenderSVGImage::styleWillChange):
+ * rendering/RenderSVGImage.h:
+ * rendering/RenderSVGInline.cpp:
+ (WebCore::RenderSVGInline::styleWillChange):
+ * rendering/RenderSVGInline.h:
+ * rendering/RenderSVGModelObject.cpp:
+ (WebCore::RenderSVGModelObject::styleWillChange):
+ * rendering/RenderSVGModelObject.h:
+ * rendering/RenderSVGRoot.cpp:
+ (WebCore::RenderSVGRoot::RenderSVGRoot):
+ (WebCore::RenderSVGRoot::layout):
+ (WebCore::RenderSVGRoot::styleWillChange):
+ (WebCore::RenderSVGRoot::updateCachedBoundaries):
+ * rendering/RenderSVGRoot.h:
+ (WebCore::RenderSVGRoot::setNeedsBoundariesUpdate):
+ (WebCore::RenderSVGRoot::setNeedsTransformUpdate):
+ (WebCore::RenderSVGRoot::objectBoundingBox):
+ (WebCore::RenderSVGRoot::strokeBoundingBox):
+ (WebCore::RenderSVGRoot::repaintRectInLocalCoordinates):
+ * rendering/RenderSVGText.cpp:
+ (WebCore::RenderSVGText::layout):
+ * rendering/RenderSVGTransformableContainer.cpp:
+ (WebCore::RenderSVGTransformableContainer::calculateLocalTransform):
+ * rendering/RenderSVGTransformableContainer.h:
+ * rendering/RenderSVGViewportContainer.cpp:
+ (WebCore::RenderSVGViewportContainer::calcViewport):
+ * rendering/SVGRenderSupport.cpp:
+ (WebCore::SVGRenderSupport::computeContainerBoundingBoxes):
+ (WebCore::SVGRenderSupport::paintInfoIntersectsRepaintRect):
+ * rendering/SVGRenderSupport.h:
+ * rendering/style/SVGRenderStyle.cpp:
+ (WebCore::SVGRenderStyle::diff):
+
2010-08-30 Leandro Pereira <leandro@profusion.mobi>
[EFL] Unreviewed. Build fix when ENABLE_WEB_SOCKETS=ON.
LayoutRepainter repainter(*this, m_everHadLayout && checkForRepaintDuringLayout());
SVGForeignObjectElement* foreign = static_cast<SVGForeignObjectElement*>(node());
+ bool updateCachedBoundariesInParents = false;
if (m_needsTransformUpdate) {
m_localTransform = foreign->animatedLocalTransform();
m_needsTransformUpdate = false;
+ updateCachedBoundariesInParents = true;
}
+ FloatRect oldViewport = m_viewport;
+
// Cache viewport boundaries
FloatPoint viewportLocation(foreign->x().value(foreign), foreign->y().value(foreign));
m_viewport = FloatRect(viewportLocation, FloatSize(foreign->width().value(foreign), foreign->height().value(foreign)));
+ if (!updateCachedBoundariesInParents)
+ updateCachedBoundariesInParents = oldViewport != m_viewport;
// Set box origin to the foreignObject x/y translation, so positioned objects in XHTML content get correct
// positions. A regular RenderBoxModelObject would pull this information from RenderStyle - in SVG those
RenderBlock::layout();
ASSERT(!needsLayout());
+ // If our bounds changed, notify the parents.
+ if (updateCachedBoundariesInParents)
+ RenderSVGBlock::setNeedsBoundariesUpdate();
+
// Invalidate all resources of this client if our layout changed.
if (layoutChanged)
SVGResourcesCache::clientLayoutChanged(this);
return 0;
}
+void RenderObject::setNeedsBoundariesUpdate()
+{
+ if (RenderObject* renderer = parent())
+ renderer->setNeedsBoundariesUpdate();
+}
+
FloatRect RenderObject::objectBoundingBox() const
{
ASSERT_NOT_REACHED();
// Unfortunately we don't have such a class yet, because it's not possible for all renderers
// to inherit from RenderSVGObject -> RenderObject (some need RenderBlock inheritance for instance)
virtual void setNeedsTransformUpdate() { }
- virtual void setNeedsBoundariesUpdate() { }
+ virtual void setNeedsBoundariesUpdate();
// Per SVG 1.1 objectBoundingBox ignores clipping, masking, filter effects, opacity and stroke-width.
// This is used for all computation of objectBoundingBox relative units and by SVGLocateable::getBBox().
if (oldChild->isPositioned() && owner->childrenInline())
owner->dirtyLinesFromChangedChild(oldChild);
+
+#if ENABLE(SVG)
+ // Update cached boundaries in SVG renderers, if a child is removed.
+ owner->setNeedsBoundariesUpdate();
+#endif
}
// If oldChild is the start or end of the selection, then clear the selection to
LayoutRepainter repainter(*this, m_everHadLayout && checkForRepaintDuringLayout());
SVGStyledTransformableElement* element = static_cast<SVGStyledTransformableElement*>(node());
+ bool updateCachedBoundariesInParents = false;
+
bool needsPathUpdate = m_needsPathUpdate;
if (needsPathUpdate) {
m_path = element->toPathData();
m_needsPathUpdate = false;
+ updateCachedBoundariesInParents = true;
}
if (m_needsTransformUpdate) {
m_localTransform = element->animatedLocalTransform();
m_needsTransformUpdate = false;
+ updateCachedBoundariesInParents = true;
}
+ if (m_needsBoundariesUpdate)
+ updateCachedBoundariesInParents = true;
+
// Invalidate all resources of this client if our layout changed.
if (m_everHadLayout && selfNeedsLayout())
SVGResourcesCache::clientLayoutChanged(this);
// At this point LayoutRepainter already grabbed the old bounds,
- // recalculate them now so repaintAfterLayout() uses the new bounds
+ // recalculate them now so repaintAfterLayout() uses the new bounds.
if (needsPathUpdate || m_needsBoundariesUpdate) {
updateCachedBoundaries();
m_needsBoundariesUpdate = false;
}
+ // If our bounds changed, notify the parents.
+ if (updateCachedBoundariesInParents)
+ RenderSVGModelObject::setNeedsBoundariesUpdate();
+
repainter.repaintAfterLayout();
setNeedsLayout(false);
}
return;
FloatRect boundingBox = repaintRectInLocalCoordinates();
- FloatRect nonLocalBoundingBox = m_localTransform.mapRect(boundingBox);
- if (!nonLocalBoundingBox.intersects(paintInfo.rect))
+ if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTransform, paintInfo))
return;
PaintInfo childPaintInfo(paintInfo);
return m_markerLayoutInfo.calculateBoundaries(markerStart, markerMid, markerEnd, svgStyle->strokeWidth().value(svgElement), m_path);
}
-void RenderPath::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
-{
- if (diff == StyleDifferenceLayout)
- setNeedsBoundariesUpdate();
- RenderSVGModelObject::styleWillChange(diff, newStyle);
-}
-
void RenderPath::updateCachedBoundaries()
{
if (m_path.isEmpty()) {
RenderPath(SVGStyledTransformableElement*);
const Path& path() const { return m_path; }
- void setNeedsBoundariesUpdate() { m_needsBoundariesUpdate = true; }
void setNeedsPathUpdate() { m_needsPathUpdate = true; }
+ virtual void setNeedsBoundariesUpdate() { m_needsBoundariesUpdate = true; }
virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }
private:
virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
- virtual void styleWillChange(StyleDifference, const RenderStyle*);
FloatRect calculateMarkerBoundsIfNeeded();
void updateCachedBoundaries();
RenderBlock::destroy();
}
+void RenderSVGBlock::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
+{
+ if (diff == StyleDifferenceLayout)
+ setNeedsBoundariesUpdate();
+ RenderBlock::styleWillChange(diff, newStyle);
+}
+
void RenderSVGBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
RenderBlock::styleDidChange(diff, oldStyle);
virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
virtual void destroy();
+ virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
virtual void updateFromElement();
};
RenderSVGContainer::RenderSVGContainer(SVGStyledElement* node)
: RenderSVGModelObject(node)
, m_drawsContents(true)
+ , m_needsBoundariesUpdate(true)
{
}
LayoutRepainter repainter(*this, m_everHadLayout && checkForRepaintDuringLayout());
// Allow RenderSVGTransformableContainer to update its transform.
- calculateLocalTransform();
+ bool updatedTransform = calculateLocalTransform();
SVGRenderSupport::layoutChildren(this, selfNeedsLayout());
if (m_everHadLayout && selfNeedsLayout())
SVGResourcesCache::clientLayoutChanged(this);
+ // At this point LayoutRepainter already grabbed the old bounds,
+ // recalculate them now so repaintAfterLayout() uses the new bounds.
+ if (m_needsBoundariesUpdate || updatedTransform) {
+ updateCachedBoundaries();
+ m_needsBoundariesUpdate = false;
+
+ // If our bounds changed, notify the parents.
+ RenderSVGModelObject::setNeedsBoundariesUpdate();
+ }
+
repainter.repaintAfterLayout();
setNeedsLayout(false);
}
if (!firstChild() && !selfWillPaint())
return;
+ FloatRect repaintRect = repaintRectInLocalCoordinates();
+ if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(repaintRect, localToParentTransform(), paintInfo))
+ return;
+
PaintInfo childPaintInfo(paintInfo);
childPaintInfo.context->save();
// FIXME: This means our focus ring won't share our rotation like it should.
// We should instead disable our clip during PaintPhaseOutline
if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && style()->visibility() == VISIBLE) {
- IntRect paintRectInParent = enclosingIntRect(localToParentTransform().mapRect(repaintRectInLocalCoordinates()));
+ IntRect paintRectInParent = enclosingIntRect(localToParentTransform().mapRect(repaintRect));
paintOutline(paintInfo.context, paintRectInParent.x(), paintRectInParent.y(), paintRectInParent.width(), paintRectInParent.height());
}
}
rects.append(paintRectInParent);
}
-FloatRect RenderSVGContainer::objectBoundingBox() const
+void RenderSVGContainer::updateCachedBoundaries()
{
- return SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::ObjectBoundingBox);
-}
+ m_objectBoundingBox = FloatRect();
+ m_strokeBoundingBox = FloatRect();
+ m_repaintBoundingBox = FloatRect();
-FloatRect RenderSVGContainer::strokeBoundingBox() const
-{
- return SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::StrokeBoundingBox);
-}
-
-FloatRect RenderSVGContainer::repaintRectInLocalCoordinates() const
-{
- FloatRect repaintRect = SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::RepaintBoundingBox);
- SVGRenderSupport::intersectRepaintRectWithResources(this, repaintRect);
- return repaintRect;
+ SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m_strokeBoundingBox, m_repaintBoundingBox);
+ SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingBox);
}
bool RenderSVGContainer::nodeAtFloatPoint(const HitTestRequest& request, HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction)
bool drawsContents() const { return m_drawsContents; }
virtual void paint(PaintInfo&, int parentX, int parentY);
+ virtual void setNeedsBoundariesUpdate() { m_needsBoundariesUpdate = true; }
protected:
virtual RenderObjectChildList* virtualChildren() { return children(); }
virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
- virtual FloatRect objectBoundingBox() const;
- virtual FloatRect strokeBoundingBox() const;
- virtual FloatRect repaintRectInLocalCoordinates() const;
+ virtual FloatRect objectBoundingBox() const { return m_objectBoundingBox; }
+ virtual FloatRect strokeBoundingBox() const { return m_strokeBoundingBox; }
+ virtual FloatRect repaintRectInLocalCoordinates() const { return m_repaintBoundingBox; }
virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
// Allow RenderSVGTransformableContainer to hook in at the right time in layout()
- virtual void calculateLocalTransform() { }
+ virtual bool calculateLocalTransform() { return false; }
// Allow RenderSVGViewportContainer to hook in at the right times in layout(), paint() and nodeAtFloatPoint()
virtual void calcViewport() { }
virtual bool pointIsInsideViewportClip(const FloatPoint& /*pointInParent*/) { return true; }
bool selfWillPaint();
+ void updateCachedBoundaries();
private:
RenderObjectChildList m_children;
+ FloatRect m_objectBoundingBox;
+ FloatRect m_strokeBoundingBox;
+ FloatRect m_repaintBoundingBox;
bool m_drawsContents : 1;
+ bool m_needsBoundariesUpdate : 1;
};
inline RenderSVGContainer* toRenderSVGContainer(RenderObject* object)
// https://bugs.webkit.org/show_bug.cgi?id=20400
virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject*) { return IntRect(); }
virtual FloatRect objectBoundingBox() const { return FloatRect(); }
+ virtual FloatRect strokeBoundingBox() const { return FloatRect(); }
virtual FloatRect repaintRectInLocalCoordinates() const { return FloatRect(); }
protected:
// This subtree does not paint.
}
-IntRect RenderSVGHiddenContainer::clippedOverflowRectForRepaint(RenderBoxModelObject* /*repaintContainer*/)
-{
- return IntRect();
-}
-
void RenderSVGHiddenContainer::absoluteQuads(Vector<FloatQuad>&)
{
// This subtree does not take up space or paint
return false;
}
-FloatRect RenderSVGHiddenContainer::objectBoundingBox() const
-{
- return FloatRect();
-}
-
-FloatRect RenderSVGHiddenContainer::repaintRectInLocalCoordinates() const
-{
- return FloatRect();
-}
-
}
#endif // ENABLE(SVG)
virtual void paint(PaintInfo&, int parentX, int parentY);
- virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
+ virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject*) { return IntRect(); }
virtual void absoluteQuads(Vector<FloatQuad>&);
- virtual FloatRect objectBoundingBox() const;
- virtual FloatRect repaintRectInLocalCoordinates() const;
-
virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
};
}
LayoutRepainter repainter(*this, m_everHadLayout && checkForRepaintDuringLayout());
SVGImageElement* image = static_cast<SVGImageElement*>(node());
+ bool updateCachedBoundariesInParents = false;
if (m_needsTransformUpdate) {
m_localTransform = image->animatedLocalTransform();
m_needsTransformUpdate = false;
+ updateCachedBoundariesInParents = true;
}
// minimum height
calcHeight();
// FIXME: Optimize caching the repaint rects.
+ FloatRect oldBoundaries = m_localBounds;
m_localBounds = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image));
m_cachedLocalRepaintRect = FloatRect();
+ if (!updateCachedBoundariesInParents)
+ updateCachedBoundariesInParents = oldBoundaries != m_localBounds;
+
// Invalidate all resources of this client if our layout changed.
if (m_everHadLayout && selfNeedsLayout())
SVGResourcesCache::clientLayoutChanged(this);
+ // If our bounds changed, notify the parents.
+ if (updateCachedBoundariesInParents)
+ RenderImage::setNeedsBoundariesUpdate();
+
repainter.repaintAfterLayout();
setNeedsLayout(false);
}
RenderImage::destroy();
}
+void RenderSVGImage::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
+{
+ if (diff == StyleDifferenceLayout)
+ setNeedsBoundariesUpdate();
+ RenderImage::styleWillChange(diff, newStyle);
+}
+
void RenderSVGImage::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
RenderImage::styleDidChange(diff, oldStyle);
virtual void paint(PaintInfo&, int parentX, int parentY);
virtual void destroy();
+ virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
virtual void updateFromElement();
RenderInline::destroy();
}
+void RenderSVGInline::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
+{
+ if (diff == StyleDifferenceLayout)
+ setNeedsBoundariesUpdate();
+ RenderInline::styleWillChange(diff, newStyle);
+}
+
void RenderSVGInline::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
RenderInline::styleDidChange(diff, oldStyle);
virtual InlineFlowBox* createInlineFlowBox();
virtual void destroy();
+ virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
virtual void updateFromElement();
};
RenderObject::destroy();
}
+void RenderSVGModelObject::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
+{
+ if (diff == StyleDifferenceLayout)
+ setNeedsBoundariesUpdate();
+ RenderObject::styleWillChange(diff, newStyle);
+}
+
void RenderSVGModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
RenderObject::styleDidChange(diff, oldStyle);
virtual void destroy();
virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
+ virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
virtual void updateFromElement();
RenderSVGRoot::RenderSVGRoot(SVGStyledElement* node)
: RenderBox(node)
, m_isLayoutSizeChanged(false)
+ , m_needsBoundariesOrTransformUpdate(true)
{
setReplaced(true);
}
SVGRenderSupport::layoutChildren(this, needsLayout);
m_isLayoutSizeChanged = false;
+ // At this point LayoutRepainter already grabbed the old bounds,
+ // recalculate them now so repaintAfterLayout() uses the new bounds.
+ if (m_needsBoundariesOrTransformUpdate) {
+ updateCachedBoundaries();
+ m_needsBoundariesOrTransformUpdate = false;
+ }
+
repainter.repaintAfterLayout();
view()->enableLayoutState();
RenderBox::destroy();
}
+void RenderSVGRoot::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
+{
+ if (diff == StyleDifferenceLayout)
+ setNeedsBoundariesUpdate();
+ RenderBox::styleWillChange(diff, newStyle);
+}
+
void RenderSVGRoot::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
RenderBox::styleDidChange(diff, oldStyle);
return m_localToParentTransform;
}
-FloatRect RenderSVGRoot::objectBoundingBox() const
-{
- return SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::ObjectBoundingBox);
-}
-
-FloatRect RenderSVGRoot::strokeBoundingBox() const
-{
- return SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::StrokeBoundingBox);
-}
-
-FloatRect RenderSVGRoot::repaintRectInLocalCoordinates() const
-{
- FloatRect repaintRect = SVGRenderSupport::computeContainerBoundingBox(this, SVGRenderSupport::RepaintBoundingBox);
-
- const SVGRenderStyle* svgStyle = style()->svgStyle();
- if (const ShadowData* shadow = svgStyle->shadow())
- shadow->adjustRectForShadow(repaintRect);
-
- repaintRect.inflate(borderAndPaddingWidth());
- return repaintRect;
-}
-
IntRect RenderSVGRoot::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer)
{
return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer);
RenderBox::mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState);
}
+void RenderSVGRoot::updateCachedBoundaries()
+{
+ m_objectBoundingBox = FloatRect();
+ m_strokeBoundingBox = FloatRect();
+ m_repaintBoundingBox = FloatRect();
+
+ SVGRenderSupport::computeContainerBoundingBoxes(this, m_objectBoundingBox, m_strokeBoundingBox, m_repaintBoundingBox);
+ SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingBox);
+
+ const SVGRenderStyle* svgStyle = style()->svgStyle();
+ if (const ShadowData* shadow = svgStyle->shadow())
+ shadow->adjustRectForShadow(m_repaintBoundingBox);
+
+ m_repaintBoundingBox.inflate(borderAndPaddingWidth());
+}
+
bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
{
IntPoint pointInContainer(_x, _y);
RenderObjectChildList* children() { return &m_children; }
bool isLayoutSizeChanged() const { return m_isLayoutSizeChanged; }
+ virtual void setNeedsBoundariesUpdate() { m_needsBoundariesOrTransformUpdate = true; }
+ virtual void setNeedsTransformUpdate() { m_needsBoundariesOrTransformUpdate = true; }
private:
virtual RenderObjectChildList* virtualChildren() { return children(); }
virtual void paint(PaintInfo&, int parentX, int parentY);
virtual void destroy();
+ virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
virtual void updateFromElement();
bool fillContains(const FloatPoint&) const;
bool strokeContains(const FloatPoint&) const;
- virtual FloatRect objectBoundingBox() const;
- virtual FloatRect strokeBoundingBox() const;
- virtual FloatRect repaintRectInLocalCoordinates() const;
+ virtual FloatRect objectBoundingBox() const { return m_objectBoundingBox; }
+ virtual FloatRect strokeBoundingBox() const { return m_strokeBoundingBox; }
+ virtual FloatRect repaintRectInLocalCoordinates() const { return m_repaintBoundingBox; }
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
void calcViewport();
bool selfWillPaint();
+ void updateCachedBoundaries();
IntSize parentOriginToBorderBox() const;
IntSize borderOriginToContentBox() const;
RenderObjectChildList m_children;
FloatSize m_viewportSize;
+ FloatRect m_objectBoundingBox;
+ FloatRect m_strokeBoundingBox;
+ FloatRect m_repaintBoundingBox;
mutable AffineTransform m_localToParentTransform;
bool m_isLayoutSizeChanged : 1;
+ bool m_needsBoundariesOrTransformUpdate : 1;
};
inline RenderSVGRoot* toRenderSVGRoot(RenderObject* object)
ASSERT(needsLayout());
LayoutRepainter repainter(*this, m_everHadLayout && checkForRepaintDuringLayout());
+ bool updateCachedBoundariesInParents = false;
if (m_needsTransformUpdate) {
SVGTextElement* text = static_cast<SVGTextElement*>(node());
m_localTransform = text->animatedLocalTransform();
m_needsTransformUpdate = false;
+ updateCachedBoundariesInParents = true;
}
// Reduced version of RenderBlock::layoutBlock(), which only takes care of SVG text.
if (!firstChild())
setChildrenInline(true);
+ // FIXME: We need to find a way to only layout the child boxes, if needed.
+ FloatRect oldBoundaries = objectBoundingBox();
ASSERT(childrenInline());
forceLayoutInlineChildren();
+ if (!updateCachedBoundariesInParents)
+ updateCachedBoundariesInParents = oldBoundaries != objectBoundingBox();
+
// Invalidate all resources of this client if our layout changed.
if (m_everHadLayout && selfNeedsLayout())
SVGResourcesCache::clientLayoutChanged(this);
+ // If our bounds changed, notify the parents.
+ if (updateCachedBoundariesInParents)
+ RenderSVGBlock::setNeedsBoundariesUpdate();
+
repainter.repaintAfterLayout();
setNeedsLayout(false);
}
{
}
-void RenderSVGTransformableContainer::calculateLocalTransform()
+bool RenderSVGTransformableContainer::calculateLocalTransform()
{
SVGStyledTransformableElement* element = static_cast<SVGStyledTransformableElement*>(node());
}
if (!element->hasTagName(SVGNames::gTag) || !static_cast<SVGGElement*>(element)->isShadowTreeContainerElement())
- return;
+ return needsUpdate;
FloatSize translation = static_cast<SVGShadowTreeContainerElement*>(element)->containerTranslation();
if (translation.width() == 0 && translation.height() == 0)
- return;
+ return needsUpdate;
// FIXME: Could optimize this case for use to avoid refetching the animatedLocalTransform() here, if only the containerTranslation() changed.
if (!needsUpdate)
m_localTransform = element->animatedLocalTransform();
m_localTransform.translate(translation.width(), translation.height());
+ return true;
}
}
virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }
private:
- virtual void calculateLocalTransform();
+ virtual bool calculateLocalTransform();
virtual AffineTransform localTransform() const { return m_localTransform; }
bool m_needsTransformUpdate : 1;
SVGElement* element = static_cast<SVGElement*>(node());
if (element->hasTagName(SVGNames::svgTag)) {
SVGSVGElement* svg = static_cast<SVGSVGElement*>(element);
+
+ FloatRect oldViewport = m_viewport;
m_viewport = FloatRect(svg->x().value(svg)
, svg->y().value(svg)
, svg->width().value(svg)
, svg->height().value(svg));
+
+ if (oldViewport != m_viewport)
+ setNeedsBoundariesUpdate();
}
}
paintInfo.context->endTransparencyLayer();
}
-FloatRect SVGRenderSupport::computeContainerBoundingBox(const RenderObject* container, ContainerBoundingBoxMode mode)
+void SVGRenderSupport::computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox)
{
- FloatRect boundingBox;
-
for (RenderObject* current = container->firstChild(); current; current = current->nextSibling()) {
- FloatRect childBoundingBox;
-
- switch (mode) {
- case ObjectBoundingBox:
- childBoundingBox = current->objectBoundingBox();
- break;
- case StrokeBoundingBox:
- childBoundingBox = current->strokeBoundingBox();
- break;
- case RepaintBoundingBox:
- childBoundingBox = current->repaintRectInLocalCoordinates();
- break;
+ if (current->isSVGHiddenContainer())
+ continue;
+
+ const AffineTransform& transform = current->localToParentTransform();
+ if (transform.isIdentity()) {
+ objectBoundingBox.unite(current->objectBoundingBox());
+ strokeBoundingBox.unite(current->strokeBoundingBox());
+ repaintBoundingBox.unite(current->repaintRectInLocalCoordinates());
+ } else {
+ objectBoundingBox.unite(transform.mapRect(current->objectBoundingBox()));
+ strokeBoundingBox.unite(transform.mapRect(current->strokeBoundingBox()));
+ repaintBoundingBox.unite(transform.mapRect(current->repaintRectInLocalCoordinates()));
}
-
- boundingBox.unite(current->localToParentTransform().mapRect(childBoundingBox));
}
+}
+
+bool SVGRenderSupport::paintInfoIntersectsRepaintRect(const FloatRect& localRepaintRect, const AffineTransform& localTransform, const PaintInfo& paintInfo)
+{
+ if (localTransform.isIdentity())
+ return localRepaintRect.intersects(paintInfo.rect);
- return boundingBox;
+ return localTransform.mapRect(localRepaintRect).intersects(paintInfo.rect);
}
const RenderSVGRoot* SVGRenderSupport::findTreeRootObject(const RenderObject* start)
#if ENABLE(SVG)
#include "PaintInfo.h"
+#include <wtf/Noncopyable.h>
+
namespace WebCore {
class FloatPoint;
class FloatRect;
-class ImageBuffer;
class RenderBoxModelObject;
class RenderObject;
class RenderStyle;
class TransformState;
// SVGRendererSupport is a helper class sharing code between all SVG renderers.
-class SVGRenderSupport {
+class SVGRenderSupport : public Noncopyable {
public:
// Used by all SVG renderers who apply clip/filter/etc. resources to the renderer content
static bool prepareToRenderSVGContent(RenderObject*, PaintInfo&);
// Determines whether the passed point lies in a clipping area
static bool pointInClippingArea(RenderObject*, const FloatPoint&);
- enum ContainerBoundingBoxMode {
- ObjectBoundingBox,
- StrokeBoundingBox,
- RepaintBoundingBox
- };
+ // Traverses all children of given container and returns the union object/stroke/repaintBoundingBox.
+ static void computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox);
- // Used to share the "walk all the children" logic between objectBoundingBox
- // and repaintRectInLocalCoordinates in RenderSVGRoot and RenderSVGContainer
- static FloatRect computeContainerBoundingBox(const RenderObject* container, ContainerBoundingBoxMode);
+ // Determines wheter the renderer needs to be painted.
+ static bool paintInfoIntersectsRepaintRect(const FloatRect& localRepaintRect, const AffineTransform& localTransform, const PaintInfo& paintInfo);
// Important functions used by nearly all SVG renderers centralizing coordinate transformations / repaint rect calculations
static IntRect clippedOverflowRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer);
// FIXME: These methods do not belong here.
static const RenderObject* findTextRootObject(const RenderObject* start);
static const RenderSVGRoot* findTreeRootObject(const RenderObject* start);
-
-private:
- // This class is not constructable.
- SVGRenderSupport();
- ~SVGRenderSupport();
};
} // namespace WebCore
|| svg_inherited_flags._joinStyle != other->svg_inherited_flags._joinStyle)
return StyleDifferenceLayout;
+ // Shadow changes require relayouts, as they affect the repaint rects.
+ if (shadowSVG != other->shadowSVG)
+ return StyleDifferenceLayout;
+
// Some stroke properties, requires relayouts, as the cached stroke boundaries need to be recalculated.
if (stroke != other->stroke) {
if (stroke->width != other->stroke->width
// NOTE: All comparisions below may only return StyleDifferenceRepaint
- // Shadow changes need to cause repaints.
- if (shadowSVG != other->shadowSVG)
- return StyleDifferenceRepaint;
-
// Painting related properties only need repaints.
if (miscNotEqual) {
if (misc->floodColor != other->misc->floodColor