• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 Apple Computer, Inc.
3  * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #include "config.h"
23 
24 #include "core/rendering/svg/RenderSVGBlock.h"
25 
26 #include "core/rendering/RenderView.h"
27 #include "core/rendering/style/ShadowList.h"
28 #include "core/rendering/svg/SVGRenderSupport.h"
29 #include "core/rendering/svg/SVGResourcesCache.h"
30 #include "core/svg/SVGElement.h"
31 
32 namespace WebCore {
33 
RenderSVGBlock(SVGElement * element)34 RenderSVGBlock::RenderSVGBlock(SVGElement* element)
35     : RenderBlockFlow(element)
36 {
37 }
38 
visualOverflowRect() const39 LayoutRect RenderSVGBlock::visualOverflowRect() const
40 {
41     LayoutRect borderRect = borderBoxRect();
42 
43     if (const ShadowList* textShadow = style()->textShadow())
44         textShadow->adjustRectForShadow(borderRect);
45 
46     return borderRect;
47 }
48 
updateFromStyle()49 void RenderSVGBlock::updateFromStyle()
50 {
51     RenderBlock::updateFromStyle();
52 
53     // RenderSVGlock, used by Render(SVGText|ForeignObject), is not allowed to call setHasOverflowClip(true).
54     // RenderBlock assumes a layer to be present when the overflow clip functionality is requested. Both
55     // Render(SVGText|ForeignObject) return 'NoLayer' on 'layerTypeRequired'. Fine for RenderSVGText.
56     //
57     // If we want to support overflow rules for <foreignObject> we can choose between two solutions:
58     // a) make RenderSVGForeignObject require layers and SVG layer aware
59     // b) reactor overflow logic out of RenderLayer (as suggested by dhyatt), which is a large task
60     //
61     // Until this is resolved, disable overflow support. Opera/FF don't support it as well at the moment (Feb 2010).
62     //
63     // Note: This does NOT affect overflow handling on outer/inner <svg> elements - this is handled
64     // manually by RenderSVGRoot - which owns the documents enclosing root layer and thus works fine.
65     setHasOverflowClip(false);
66 }
67 
absoluteRects(Vector<IntRect> &,const LayoutPoint &) const68 void RenderSVGBlock::absoluteRects(Vector<IntRect>&, const LayoutPoint&) const
69 {
70     // This code path should never be taken for SVG, as we're assuming useTransforms=true everywhere, absoluteQuads should be used.
71     ASSERT_NOT_REACHED();
72 }
73 
willBeDestroyed()74 void RenderSVGBlock::willBeDestroyed()
75 {
76     SVGResourcesCache::clientDestroyed(this);
77     RenderBlockFlow::willBeDestroyed();
78 }
79 
styleDidChange(StyleDifference diff,const RenderStyle * oldStyle)80 void RenderSVGBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
81 {
82     if (diff.needsFullLayout())
83         setNeedsBoundariesUpdate();
84 
85     RenderBlock::styleDidChange(diff, oldStyle);
86     SVGResourcesCache::clientStyleChanged(this, diff, style());
87 }
88 
mapLocalToContainer(const RenderLayerModelObject * repaintContainer,TransformState & transformState,MapCoordinatesFlags,bool * wasFixed) const89 void RenderSVGBlock::mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags, bool* wasFixed) const
90 {
91     SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed);
92 }
93 
pushMappingToContainer(const RenderLayerModelObject * ancestorToStopAt,RenderGeometryMap & geometryMap) const94 const RenderObject* RenderSVGBlock::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
95 {
96     return SVGRenderSupport::pushMappingToContainer(this, ancestorToStopAt, geometryMap);
97 }
98 
clippedOverflowRectForPaintInvalidation(const RenderLayerModelObject * paintInvalidationContainer) const99 LayoutRect RenderSVGBlock::clippedOverflowRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer) const
100 {
101     return SVGRenderSupport::clippedOverflowRectForRepaint(this, paintInvalidationContainer);
102 }
103 
computeFloatRectForPaintInvalidation(const RenderLayerModelObject * paintInvalidationContainer,FloatRect & paintInvalidationRect,bool fixed) const104 void RenderSVGBlock::computeFloatRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, FloatRect& paintInvalidationRect, bool fixed) const
105 {
106     SVGRenderSupport::computeFloatRectForRepaint(this, paintInvalidationContainer, paintInvalidationRect, fixed);
107 }
108 
nodeAtPoint(const HitTestRequest &,HitTestResult &,const HitTestLocation &,const LayoutPoint &,HitTestAction)109 bool RenderSVGBlock::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction)
110 {
111     ASSERT_NOT_REACHED();
112     return false;
113 }
114 
invalidateTreeAfterLayout(const RenderLayerModelObject & paintInvalidationContainer)115 void RenderSVGBlock::invalidateTreeAfterLayout(const RenderLayerModelObject& paintInvalidationContainer)
116 {
117     if (!shouldCheckForPaintInvalidationAfterLayout())
118         return;
119 
120     ForceHorriblySlowRectMapping slowRectMapping(*this);
121     RenderBlockFlow::invalidateTreeAfterLayout(paintInvalidationContainer);
122 }
123 
124 }
125