1/*
2 * Copyright (C) 2006 Apple 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#include "RenderSVGBlock.h"
24
25#include "RenderSVGResource.h"
26#include "SVGResourcesCache.h"
27#include "StyleInheritedData.h"
28
29namespace WebCore {
30
31RenderSVGBlock::RenderSVGBlock(SVGGraphicsElement& element, PassRef<RenderStyle> style)
32    : RenderBlockFlow(element, WTF::move(style))
33{
34}
35
36LayoutRect RenderSVGBlock::visualOverflowRect() const
37{
38    LayoutRect borderRect = borderBoxRect();
39
40    if (const ShadowData* textShadow = style().textShadow())
41        textShadow->adjustRectForShadow(borderRect);
42
43    return borderRect;
44}
45
46void RenderSVGBlock::updateFromStyle()
47{
48    RenderBlockFlow::updateFromStyle();
49
50    // RenderSVGlock, used by Render(SVGText|ForeignObject), is not allowed to call setHasOverflowClip(true).
51    // RenderBlock assumes a layer to be present when the overflow clip functionality is requested. Both
52    // Render(SVGText|ForeignObject) return 'false' on 'requiresLayer'. Fine for RenderSVGText.
53    //
54    // If we want to support overflow rules for <foreignObject> we can choose between two solutions:
55    // a) make RenderSVGForeignObject require layers and SVG layer aware
56    // b) reactor overflow logic out of RenderLayer (as suggested by dhyatt), which is a large task
57    //
58    // Until this is resolved, disable overflow support. Opera/FF don't support it as well at the moment (Feb 2010).
59    //
60    // Note: This does NOT affect overflow handling on outer/inner <svg> elements - this is handled
61    // manually by RenderSVGRoot - which owns the documents enclosing root layer and thus works fine.
62    setHasOverflowClip(false);
63}
64
65void RenderSVGBlock::absoluteRects(Vector<IntRect>&, const LayoutPoint&) const
66{
67    // This code path should never be taken for SVG, as we're assuming useTransforms=true everywhere, absoluteQuads should be used.
68    ASSERT_NOT_REACHED();
69}
70
71void RenderSVGBlock::willBeDestroyed()
72{
73    SVGResourcesCache::clientDestroyed(*this);
74    RenderBlockFlow::willBeDestroyed();
75}
76
77void RenderSVGBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
78{
79    if (diff == StyleDifferenceLayout)
80        setNeedsBoundariesUpdate();
81    RenderBlockFlow::styleDidChange(diff, oldStyle);
82    SVGResourcesCache::clientStyleChanged(*this, diff, style());
83}
84
85}
86