| OLD | NEW |
| 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 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2007, 2008 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. 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 * | 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 |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include "config.h" | 24 #include "config.h" |
| 25 | 25 |
| 26 #include "core/rendering/svg/RenderSVGContainer.h" | 26 #include "core/rendering/svg/RenderSVGContainer.h" |
| 27 | 27 |
| 28 #include "core/frame/Settings.h" | 28 #include "core/paint/SVGContainerPainter.h" |
| 29 #include "core/rendering/GraphicsContextAnnotator.h" | |
| 30 #include "core/rendering/RenderView.h" | 29 #include "core/rendering/RenderView.h" |
| 31 #include "core/rendering/svg/SVGRenderSupport.h" | 30 #include "core/rendering/svg/SVGRenderSupport.h" |
| 32 #include "core/rendering/svg/SVGRenderingContext.h" | |
| 33 #include "core/rendering/svg/SVGResources.h" | 31 #include "core/rendering/svg/SVGResources.h" |
| 34 #include "core/rendering/svg/SVGResourcesCache.h" | 32 #include "core/rendering/svg/SVGResourcesCache.h" |
| 35 #include "platform/graphics/GraphicsContextCullSaver.h" | |
| 36 #include "platform/graphics/GraphicsContextStateSaver.h" | |
| 37 | 33 |
| 38 namespace blink { | 34 namespace blink { |
| 39 | 35 |
| 40 RenderSVGContainer::RenderSVGContainer(SVGElement* node) | 36 RenderSVGContainer::RenderSVGContainer(SVGElement* node) |
| 41 : RenderSVGModelObject(node) | 37 : RenderSVGModelObject(node) |
| 42 , m_objectBoundingBoxValid(false) | 38 , m_objectBoundingBoxValid(false) |
| 43 , m_needsBoundariesUpdate(true) | 39 , m_needsBoundariesUpdate(true) |
| 44 { | 40 { |
| 45 } | 41 } |
| 46 | 42 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 RenderSVGModelObject::addChild(child, beforeChild); | 85 RenderSVGModelObject::addChild(child, beforeChild); |
| 90 SVGResourcesCache::clientWasAddedToTree(child, child->style()); | 86 SVGResourcesCache::clientWasAddedToTree(child, child->style()); |
| 91 } | 87 } |
| 92 | 88 |
| 93 void RenderSVGContainer::removeChild(RenderObject* child) | 89 void RenderSVGContainer::removeChild(RenderObject* child) |
| 94 { | 90 { |
| 95 SVGResourcesCache::clientWillBeRemovedFromTree(child); | 91 SVGResourcesCache::clientWillBeRemovedFromTree(child); |
| 96 RenderSVGModelObject::removeChild(child); | 92 RenderSVGModelObject::removeChild(child); |
| 97 } | 93 } |
| 98 | 94 |
| 99 | |
| 100 bool RenderSVGContainer::selfWillPaint() | 95 bool RenderSVGContainer::selfWillPaint() |
| 101 { | 96 { |
| 102 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
this); | 97 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
this); |
| 103 return resources && resources->filter(); | 98 return resources && resources->filter(); |
| 104 } | 99 } |
| 105 | 100 |
| 106 void RenderSVGContainer::paint(PaintInfo& paintInfo, const LayoutPoint&) | 101 void RenderSVGContainer::paint(PaintInfo& paintInfo, const LayoutPoint&) |
| 107 { | 102 { |
| 108 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 103 SVGContainerPainter(*this).paint(paintInfo); |
| 109 | |
| 110 // Spec: groups w/o children still may render filter content. | |
| 111 if (!firstChild() && !selfWillPaint()) | |
| 112 return; | |
| 113 | |
| 114 FloatRect paintInvalidationRect = paintInvalidationRectInLocalCoordinates(); | |
| 115 if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(paintInvalid
ationRect, localToParentTransform(), paintInfo)) | |
| 116 return; | |
| 117 | |
| 118 PaintInfo childPaintInfo(paintInfo); | |
| 119 { | |
| 120 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); | |
| 121 | |
| 122 // Let the RenderSVGViewportContainer subclass clip if necessary | |
| 123 applyViewportClip(childPaintInfo); | |
| 124 | |
| 125 childPaintInfo.applyTransform(localToParentTransform()); | |
| 126 | |
| 127 SVGRenderingContext renderingContext; | |
| 128 GraphicsContextCullSaver cullSaver(*childPaintInfo.context); | |
| 129 bool continueRendering = true; | |
| 130 if (childPaintInfo.phase == PaintPhaseForeground) { | |
| 131 renderingContext.prepareToRenderSVGContent(this, childPaintInfo); | |
| 132 continueRendering = renderingContext.isRenderingPrepared(); | |
| 133 | |
| 134 if (continueRendering && document().settings()->containerCullingEnab
led()) | |
| 135 cullSaver.cull(paintInvalidationRectInLocalCoordinates()); | |
| 136 } | |
| 137 | |
| 138 if (continueRendering) { | |
| 139 childPaintInfo.updatePaintingRootForChildren(this); | |
| 140 for (RenderObject* child = firstChild(); child; child = child->nextS
ibling()) | |
| 141 child->paint(childPaintInfo, IntPoint()); | |
| 142 } | |
| 143 } | |
| 144 | |
| 145 // FIXME: This really should be drawn from local coordinates, but currently
we hack it | |
| 146 // to avoid our clip killing our outline rect. Thus we translate our | |
| 147 // outline rect into parent coords before drawing. | |
| 148 // FIXME: This means our focus ring won't share our rotation like it should. | |
| 149 // We should instead disable our clip during PaintPhaseOutline | |
| 150 if (paintInfo.phase == PaintPhaseForeground && style()->outlineWidth() && st
yle()->visibility() == VISIBLE) { | |
| 151 IntRect paintRectInParent = enclosingIntRect(localToParentTransform().ma
pRect(paintInvalidationRect)); | |
| 152 paintOutline(paintInfo, paintRectInParent); | |
| 153 } | |
| 154 } | 104 } |
| 155 | 105 |
| 156 // addFocusRingRects is called from paintOutline and needs to be in the same coo
rdinates as the paintOuline call | 106 // addFocusRingRects is called from paintOutline and needs to be in the same coo
rdinates as the paintOuline call |
| 157 void RenderSVGContainer::addFocusRingRects(Vector<LayoutRect>& rects, const Layo
utPoint&, const RenderLayerModelObject*) const | 107 void RenderSVGContainer::addFocusRingRects(Vector<LayoutRect>& rects, const Layo
utPoint&, const RenderLayerModelObject*) const |
| 158 { | 108 { |
| 159 LayoutRect paintRectInParent = LayoutRect(localToParentTransform().mapRect(p
aintInvalidationRectInLocalCoordinates())); | 109 LayoutRect paintRectInParent = LayoutRect(localToParentTransform().mapRect(p
aintInvalidationRectInLocalCoordinates())); |
| 160 if (!paintRectInParent.isEmpty()) | 110 if (!paintRectInParent.isEmpty()) |
| 161 rects.append(paintRectInParent); | 111 rects.append(paintRectInParent); |
| 162 } | 112 } |
| 163 | 113 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 190 if (objectBoundingBox().contains(localPoint)) { | 140 if (objectBoundingBox().contains(localPoint)) { |
| 191 updateHitTestResult(result, roundedLayoutPoint(localPoint)); | 141 updateHitTestResult(result, roundedLayoutPoint(localPoint)); |
| 192 return true; | 142 return true; |
| 193 } | 143 } |
| 194 } | 144 } |
| 195 // 16.4: "If there are no graphics elements whose relevant graphics content
is under the pointer (i.e., there is no target element), the event is not dispat
ched." | 145 // 16.4: "If there are no graphics elements whose relevant graphics content
is under the pointer (i.e., there is no target element), the event is not dispat
ched." |
| 196 return false; | 146 return false; |
| 197 } | 147 } |
| 198 | 148 |
| 199 } | 149 } |
| OLD | NEW |