Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / svg / RenderSVGBlock.cpp
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/style/ShadowList.h"
27 #include "core/rendering/svg/SVGRenderSupport.h"
28 #include "core/rendering/svg/SVGResourcesCache.h"
29 #include "core/svg/SVGElement.h"
30
31 namespace WebCore {
32
33 RenderSVGBlock::RenderSVGBlock(SVGElement* element)
34     : RenderBlockFlow(element)
35 {
36 }
37
38 LayoutRect RenderSVGBlock::visualOverflowRect() const
39 {
40     LayoutRect borderRect = borderBoxRect();
41
42     if (const ShadowList* textShadow = style()->textShadow())
43         textShadow->adjustRectForShadow(borderRect);
44
45     return borderRect;
46 }
47
48 void RenderSVGBlock::updateFromStyle()
49 {
50     RenderBlock::updateFromStyle();
51
52     // RenderSVGlock, used by Render(SVGText|ForeignObject), is not allowed to call setHasOverflowClip(true).
53     // RenderBlock assumes a layer to be present when the overflow clip functionality is requested. Both
54     // Render(SVGText|ForeignObject) return 'NoLayer' on 'layerTypeRequired'. Fine for RenderSVGText.
55     //
56     // If we want to support overflow rules for <foreignObject> we can choose between two solutions:
57     // a) make RenderSVGForeignObject require layers and SVG layer aware
58     // b) reactor overflow logic out of RenderLayer (as suggested by dhyatt), which is a large task
59     //
60     // Until this is resolved, disable overflow support. Opera/FF don't support it as well at the moment (Feb 2010).
61     //
62     // Note: This does NOT affect overflow handling on outer/inner <svg> elements - this is handled
63     // manually by RenderSVGRoot - which owns the documents enclosing root layer and thus works fine.
64     setHasOverflowClip(false);
65 }
66
67 void RenderSVGBlock::absoluteRects(Vector<IntRect>&, const LayoutPoint&) const
68 {
69     // This code path should never be taken for SVG, as we're assuming useTransforms=true everywhere, absoluteQuads should be used.
70     ASSERT_NOT_REACHED();
71 }
72
73 void RenderSVGBlock::willBeDestroyed()
74 {
75     SVGResourcesCache::clientDestroyed(this);
76     RenderBlockFlow::willBeDestroyed();
77 }
78
79 void RenderSVGBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
80 {
81     if (diff == StyleDifferenceLayout)
82         setNeedsBoundariesUpdate();
83
84     RenderBlock::styleDidChange(diff, oldStyle);
85     SVGResourcesCache::clientStyleChanged(this, diff, style());
86 }
87
88 void RenderSVGBlock::mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags, bool* wasFixed) const
89 {
90     SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed);
91 }
92
93 const RenderObject* RenderSVGBlock::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
94 {
95     return SVGRenderSupport::pushMappingToContainer(this, ancestorToStopAt, geometryMap);
96 }
97
98 LayoutRect RenderSVGBlock::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
99 {
100     return SVGRenderSupport::clippedOverflowRectForRepaint(this, repaintContainer);
101 }
102
103 void RenderSVGBlock::computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect& repaintRect, bool fixed) const
104 {
105     SVGRenderSupport::computeFloatRectForRepaint(this, repaintContainer, repaintRect, fixed);
106 }
107
108 bool RenderSVGBlock::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction)
109 {
110     ASSERT_NOT_REACHED();
111     return false;
112 }
113
114 }